Tstamppublic class Tstamp extends org.apache.tools.ant.Task Sets properties to the current time, or offsets from the current time.
The default properties are TSTAMP, DSTAMP and TODAY; |
Fields Summary |
---|
private Vector | customFormats | private String | prefix |
Methods Summary |
---|
public org.apache.tools.ant.taskdefs.Tstamp$CustomFormat | createFormat()create a custom format with the current prefix.
CustomFormat cts = new CustomFormat();
customFormats.addElement(cts);
return cts;
| public void | execute()create the timestamps. Custom ones are done before
the standard ones, to get their retaliation in early.
try {
Date d = new Date();
Enumeration i = customFormats.elements();
while (i.hasMoreElements()) {
CustomFormat cts = (CustomFormat) i.nextElement();
cts.execute(getProject(), d, getLocation());
}
SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd");
setProperty("DSTAMP", dstamp.format(d));
SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm");
setProperty("TSTAMP", tstamp.format(d));
SimpleDateFormat today
= new SimpleDateFormat ("MMMM d yyyy", Locale.US);
setProperty("TODAY", today.format(d));
} catch (Exception e) {
throw new BuildException(e);
}
| public void | setPrefix(java.lang.String prefix)Set a prefix for the properties. If the prefix does not end with a "."
one is automatically added.
this.prefix = prefix;
if (!this.prefix.endsWith(".")) {
this.prefix += ".";
}
| private void | setProperty(java.lang.String name, java.lang.String value)helper that encapsulates prefix logic and property setting
policy (i.e. we use setNewProperty instead of setProperty).
getProject().setNewProperty(prefix + name, value);
|
|