Class FormatType

java.lang.Object
org.oddjob.values.types.FormatType
All Implemented Interfaces:
Serializable, ArooaValue

public class FormatType extends Object implements ArooaValue, Serializable
Author:
Rob Gordon.
See Also:

Description

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

Form more information on the number format see DecimalFormat

For more information on the date format see SimpleDateFormat

Example

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.

  • Constructor Details

    • FormatType

      public FormatType()
  • Method Details

    • setDate

      public void setDate(Date date)
    • setFormat

      public void setFormat(String format)
    • setTimeZone

      public void setTimeZone(String timeZoneId)
    • setNumber

      public void setNumber(Number number)
    • toString

      public String toString()
      Overrides:
      toString in class Object