Package org.oddjob.values.types
Class DateType
java.lang.Object
org.oddjob.values.types.DateType
- All Implemented Interfaces:
Serializable,ArooaValue
- Author:
- Rob Gordon.
- See Also:
- yyyy-MM-dd
- Just the date.
- yyyy-MM-dd HH:mm
- The date, hours and minutes.
- yyyy-MM-dd HH:mm:ss
- The date, hours, minutes and seconds.
- yyyy-MM-dd HH:mm:ss.SSS
- The date, hours, minutes, seconds and milliseconds.
- The text format of the date is not in one of the formats above.
- The date must be specified in a different time zone.
- NOW
- The date and time now.
- TODAY
- The date as of midnight.
- YESTERDAY
- The date yesterday at midnight.
- TOMORROW
- The date tomorrow at midnight.
Description
Define a Date.Oddjob's inbuilt conversion allows a date to be specified as text in any of these formats:
Because of this a date property of a job can be specified perfectly
easily as a ValueType or a property. However there are two situations
when this is inadequate:
In either or both of these cases the date type can be used.
This date type can also be used to specify a java Calendar property which Oddjob's inbuilt conversion will currently not do from text.
Since v1.3 The date can also be specified using one of these shortcuts:
Example
A simple example of specifying a date.<date date="2009-12-25 12:30"/>Specifying a date in a different format.
<date date="25/12/2009 12:30" format="dd/MM/yyyy HH:mm"/>Adjusting a date by Time Zone.
<sequential>
<jobs>
<variables id="vars">
<xmas>
<date timeZone="US/Hawaii" date="2009-12-25"/>
</xmas>
</variables>
<echo>Christmas in Hawaii starts at ${vars.xmas}.</echo>
</jobs>
</sequential>
Date shortcuts.
<oddjob>
<job>
<sequential>
<jobs>
<variables id="vars">
<now>
<date date="NOW"/>
</now>
<today>
<date date="TODAY"/>
</today>
<yesterday>
<date date="YESTERDAY"/>
</yesterday>
<tomorrow>
<date date="TOMORROW"/>
</tomorrow>
</variables>
<echo>Today is ${vars.today}.
The date/time now is ${vars.now}.
Yesterday was ${vars.yesterday}.
Tomorrow is ${vars.tomorrow}.</echo>
</jobs>
</sequential>
</job>
</oddjob>
-
Constructor Details
-
DateType
public DateType()
-
-
Method Details
-
toCalandar
- Throws:
ParseException
-
toDate
Convert this type to a date.- Returns:
- A date. May be null if the date property is null.
- Throws:
ParseException
-
setDate
-
getDate
-
getFormat
-
setFormat
-
setTimeZone
-
getTimeZone
-
getClock
-
setClock
-
toString
-