1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
---
layout: default
class: Macro
title: now ( 'long' | DATEFORMAT )
summary: Current date and time, default is default Date format. The format can be specified as a long or a date format.
---
public final static String _nowHelp = "${now;pattern|'long'}, returns current time";
public Object _now(String args[]) {
verifyCommand(args, _nowHelp, null, 1, 2);
Date now = new Date();
if (args.length == 2) {
if ("long".equals(args[1]))
return now.getTime();
DateFormat df = new SimpleDateFormat(args[1]);
return df.format(now);
}
return now;
}
|