Package ise.antelope.tasks
Class DateTimeDifference
- java.lang.Object
-
- ise.antelope.tasks.DateTimeDifference
-
- All Implemented Interfaces:
org.apache.tools.ant.taskdefs.condition.Condition
public class DateTimeDifference extends java.lang.Object implements org.apache.tools.ant.taskdefs.condition.ConditionCondition that validates the difference between two date/time stamps.- Version:
- $Revision: 132 $
-
-
Constructor Summary
Constructors Constructor Description DateTimeDifference()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleaneval()voidsetDatetime1(java.lang.String date)Sets a date/timestamp, required.voidsetDatetime2(java.lang.String date)Sets the other date/time stamp, required.voidsetFormat(java.lang.String format)Sets the format of the datetimes, this is a required attribute.voidsetLenient(boolean b)Sets whether the datetime parser should use lenient parsing.voidsetUnit(java.lang.String unit)Sets the unit for the difference between the 2 datetimes.voidsetValue(int value)Sets the expected difference between the 2 datetimes.
-
-
-
Method Detail
-
setDatetime1
public void setDatetime1(java.lang.String date)
Sets a date/timestamp, required.- Parameters:
date- a string representing a date or time.
-
setDatetime2
public void setDatetime2(java.lang.String date)
Sets the other date/time stamp, required.- Parameters:
date- a string representing a date or time.
-
setFormat
public void setFormat(java.lang.String format)
Sets the format of the datetimes, this is a required attribute. See java.text.SimpleDateFormat for the format.- Parameters:
format- The new format value
-
setLenient
public void setLenient(boolean b)
Sets whether the datetime parser should use lenient parsing. This is an optional setting, default is true, use lenient parsing.- Parameters:
b- The new lenient value
-
setValue
public void setValue(int value)
Sets the expected difference between the 2 datetimes.- Parameters:
value- the expected difference.
-
setUnit
public void setUnit(java.lang.String unit)
Sets the unit for the difference between the 2 datetimes. For example, ifvalueis 12 andunitis "hours", then this condition checks that the difference between the 2 datetimes is 12 hours.- Parameters:
unit- valid values are "millisecond", "second", "minute", "hour", "day", "week", "month", "year".
-
eval
public boolean eval() throws org.apache.tools.ant.BuildException- Specified by:
evalin interfaceorg.apache.tools.ant.taskdefs.condition.Condition- Returns:
- true if the difference between the two dates or times is the same as the expected value.
- Throws:
org.apache.tools.ant.BuildException- if the attributes are not set correctly
-
-