Tstamp.CustomFormat (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs, class: Tstamp, class: CustomFormat

Package org.apache.tools.ant.taskdefs

# Class Tstamp.CustomFormat

java.lang.Object
org.apache.tools.ant.taskdefs.Tstamp.CustomFormat

Enclosing class:
  Tstamp

    public class Tstamp.CustomFormat
    extends java.lang.Object

This nested element that allows a property to be set to the current date and time in a given format. The date/time patterns are as defined in the Java SimpleDateFormat class. The format element also allows offsets to be applied to the time to generate different time values.

To do:
  consider refactoring out into a re-usable element.

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `CustomFormat()` |

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `execute​(Project project, java.util.Date date, Location location)` | validate parameter and execute the format.
  `void` | `setLocale​(java.lang.String locale)` | The locale used to create date/time string.
  `void` | `setOffset​(int offset)` | The numeric offset to the current time.
  `void` | `setPattern​(java.lang.String pattern)` | The date/time pattern to be used.
  `void` | `setProperty​(java.lang.String propertyName)` | The property to receive the date/time string in the given pattern
  `void` | `setTimezone​(java.lang.String id)` | The timezone to use for displaying time.
  `void` | `setUnit​(java.lang.String unit)` | Deprecated. since 1.5.x.
  `void` | `setUnit​(Tstamp.Unit unit)` | The unit of the offset to be applied to the current time.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CustomFormat

    public CustomFormat()

- ## Method Details

  - ### setProperty

    public void setProperty​(java.lang.String propertyName)
    The property to receive the date/time string in the given pattern
    Parameters:
      `propertyName` - the name of the property.

  - ### setPattern

    public void setPattern​(java.lang.String pattern)
    The date/time pattern to be used. The values are as defined by the Java SimpleDateFormat class.
    Parameters:
      `pattern` - the pattern to use.
    See Also:
      `SimpleDateFormat`

  - ### setLocale

    public void setLocale​(java.lang.String locale)
    The locale used to create date/time string. The general form is "language, country, variant" but either variant or variant and country may be omitted. For more information please refer to documentation for the java.util.Locale class.
    Parameters:
      `locale` - the locale to use.
    See Also:
      `Locale`

  - ### setTimezone

    public void setTimezone​(java.lang.String id)
    The timezone to use for displaying time. The values are as defined by the Java TimeZone class.
    Parameters:
      `id` - the timezone value.
    See Also:
      `TimeZone`

  - ### setOffset

    public void setOffset​(int offset)
    The numeric offset to the current time.
    Parameters:
      `offset` - the offset to use.

  - ### setUnit

    @Deprecated public void setUnit​(java.lang.String unit)
    Deprecated.
    since 1.5.x. setUnit(String) is deprecated and is replaced with setUnit(Tstamp.Unit) to make Ant's Introspection mechanism do the work and also to encapsulate operations on the unit in its own class.
    Set the unit type (using String).
    Parameters:
      `unit` - the unit to use.

  - ### setUnit

    public void setUnit​(Tstamp.Unit unit)
    The unit of the offset to be applied to the current time. Valid Values are
    - millisecond
    - second
    - minute
    - hour
    - day
    - week
    - month
    - year
    The default unit is day.
    Parameters:
      `unit` - the unit to use.

  - ### execute

    public void execute​(Project project, java.util.Date date, Location location)
    validate parameter and execute the format.
    Parameters:
      `project` - project to set property in.
      `date` - date to use as a starting point.
      `location` - line in file (for errors)