Methods Summary |
---|
public synchronized java.lang.String | getDatetime()Get the date & time in String format.
return dateTime;
|
public synchronized long | getGranularity()Get the timestamp granularity used by this ResourceSelector.
return granularity;
|
public synchronized long | getMillis()Get the date/time in ms.
return millis == null ? -1L : millis.longValue();
|
public synchronized java.lang.String | getPattern()Get the pattern for use with the datetime attribute.
return pattern;
|
public synchronized org.apache.tools.ant.types.TimeComparison | getWhen()Get the comparison mode.
return when;
|
public synchronized boolean | isSelected(org.apache.tools.ant.types.Resource r)Return true if this Resource is selected.
if (dateTime == null && millis == null) {
throw new BuildException(MILLIS_OR_DATETIME);
}
if (millis == null) {
DateFormat df = ((pattern == null)
? DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT, Locale.US)
: new SimpleDateFormat(pattern));
try {
long m = df.parse(dateTime).getTime();
if (m < 0) {
throw new BuildException("Date of " + dateTime
+ " results in negative milliseconds value"
+ " relative to epoch (January 1, 1970, 00:00:00 GMT).");
}
setMillis(m);
} catch (ParseException pe) {
throw new BuildException("Date of " + dateTime
+ " Cannot be parsed correctly. It should be in"
+ (pattern == null
? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format.");
}
}
return when.evaluate(r.getLastModified(), millis.longValue(), granularity);
|
public synchronized void | setDateTime(java.lang.String s)Set the date and time as a String.
dateTime = s;
millis = null;
|
public synchronized void | setGranularity(long g)Set the granularity to use for this ResourceSelector.
granularity = g;
|
public synchronized void | setMillis(long m)Set the date/time in milliseconds since 1970.
millis = new Long(m);
|
public synchronized void | setPattern(java.lang.String p)Set the optional pattern to use with the datetime attribute.
pattern = p;
|
public synchronized void | setWhen(org.apache.tools.ant.types.TimeComparison c)Set the comparison mode.
when = c;
|