[Index]

format


A type which can either format a number or a date into the given text format.

Form more information on the number format see java.text.DecimalFormat

For more information on the date format see java.text.SimpleDateFormat


Property Summary

date A date to format.
format The format.
number A number to format.
timeZone The time zone to use for a date format.

Example Summary

Example 1 Formatting a date and number to create a file name.
Example 2 Format the current time as a property.

Property Detail

date

Configured ByATTRIBUTE
AccessWRITE_ONLY
RequiredYes if number isn't supplied.

A date to format.

format

Configured ByATTRIBUTE
AccessWRITE_ONLY
RequiredYes.

The format.

number

Configured ByATTRIBUTE
AccessWRITE_ONLY
RequiredYes if date isn't supplied.

A number to format.

timeZone

Configured ByATTRIBUTE
AccessWRITE_ONLY
RequiredNo.

The time zone to use for a date format.


Examples

Example 1

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>

Example 2

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.


(c) Rob Gordon 2005 - 2017