org.oddjob.values.types
Class DateType
java.lang.Object
org.oddjob.values.types.DateType
- All Implemented Interfaces:
- Serializable, ArooaValue
public class DateType
- extends Object
- implements ArooaValue, Serializable
Description
Define a Date.
Oddjob's inbuilt conversion allows a date to be specified as text in
any of these formats:
- 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.
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:
- The text format of the date is not in one of the formats above.
- The date must be specified in a different time zone.
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:
- NOW
- The date and time now.
- TODAY
- The date as of midnight.
- YESTERDAY
- The date yesterday at midnight.
- TOMORROW
- The date tomorrow at midnight.
Example
A simple example of specifying a date.
<date date="2009-12-25 12:30"/>
Example
Specifying a date in a different format.
<date date="25/12/2009 12:30" format="dd/MM/yyyy HH:mm"/>
Example
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>
- See Also:
- Serialized Form
- Author:
- Rob Gordon.
DateType
public DateType()
toCalandar
public Calendar toCalandar()
throws ParseException
- Throws:
ParseException
toDate
public Date toDate()
throws ParseException
- Convert this type to a date.
- Returns:
- A date. May be null if the date property is null.
- Throws:
ParseException
setDate
public void setDate(String date)
getDate
public String getDate()
getFormat
public String getFormat()
setFormat
public void setFormat(String format)
setTimeZone
public void setTimeZone(String timeZoneId)
getTimeZone
public String getTimeZone()
getClock
public Clock getClock()
setClock
public void setClock(Clock clock)
toString
public String toString()
- Overrides:
toString
in class Object