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 value 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:
| clock | The clock to use if a date shortcut is specified. |
| date | A date in text, if a format is specified it is expected to be in the format provide, otherwise it is expected to be in the default format.. |
| format | The format the date is in. |
| timeZone | The time zone the date is for. |
| Example 1 | A simple example of specifying a date. |
| Example 2 | Specifying a date in a different format. |
| Example 3 | Adjusting a date by Time Zone. |
| Example 4 | Date shortcuts. |
| Configured By | ELEMENT |
| Access | READ_WRITE |
| Required | No, defaults to the current time clock. |
The clock to use if a date shortcut is specified. This is mainly here for tests.
| Configured By | ATTRIBUTE |
| Access | READ_WRITE |
| Required | Yes. |
A date in text, if a format is specified it is expected to be in the format provide, otherwise it is expected to be in the default format..
| Configured By | ATTRIBUTE |
| Access | READ_WRITE |
| Required | No. |
The format the date is in.
| Configured By | ATTRIBUTE |
| Access | READ_WRITE |
| Required | No. |
The time zone the date is for.
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>