Form more information on the number format see java.text.DecimalFormat
For more information on the date format see java.text.SimpleDateFormat
date | A date to format. |
format | The format. |
number | A number to format. |
timeZone | The time zone to use for a date format. |
Example 1 | Formatting a date and number to create a file name. |
Example 2 | Format the current time as a property. |
Configured By | ATTRIBUTE |
Access | WRITE_ONLY |
Required | Yes if number isn't supplied. |
A date to format.
Configured By | ATTRIBUTE |
Access | WRITE_ONLY |
Required | Yes. |
The format.
Configured By | ATTRIBUTE |
Access | WRITE_ONLY |
Required | Yes if date isn't supplied. |
A number to format.
Configured By | ATTRIBUTE |
Access | WRITE_ONLY |
Required | No. |
The time zone to use for a date format.
Formatting a date and number to create a file name.
<oddjob> <job> <sequential> <jobs> <variables id="vars"> <businessDate> <format format="yyyyMMdd" date="2005-12-25"/> </businessDate> <sequence> <format format="000000" number="123"/> </sequence> </variables> <exists id="file-check" file="Data-${vars.businessDate}-${vars.sequence}.dat"/> </jobs> </sequential> </job> </oddjob>
Format the current time as a property.
<oddjob> <job> <sequential> <jobs> <properties> <values> <date date="NOW" key="date-time.now"> <clock> <value value="${our-clock}"/> </clock> </date> <format date="${date-time.now}" format="h:mm a" key="time.now.formatted"/> </values> </properties> <echo>The time is ${time.now.formatted}.</echo> </jobs> </sequential> </job> </oddjob>Note that the
our-clock
reference is provided for the tests
but when not provided (if this is run as is) the current time is used.
An example of the output is:
The time is 8:17 AM.