org.springframework.format.datetime.joda

## Class DateTimeFormatterFactory

- java.lang.Object
- - org.springframework.format.datetime.joda.DateTimeFormatterFactory

- Direct Known Subclasses:
    DateTimeFormatterFactoryBean

      public class DateTimeFormatterFactory
      extends Object

  Factory that creates a Joda `DateTimeFormatter`. Formatters will be created using the defined `pattern`, `ISO`, or `style` (considered in that order).
  Since:
    3.2
  Author:
    Phillip Webb, Sam Brannen
  See Also:
    `createDateTimeFormatter()`, `createDateTimeFormatter(DateTimeFormatter)`, `setPattern(String)`, `setIso(org.springframework.format.annotation.DateTimeFormat.ISO)`, `setStyle(String)`, `DateTimeFormatterFactoryBean`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DateTimeFormatterFactory()` Create a new `DateTimeFormatterFactory` instance.
    `DateTimeFormatterFactory(String pattern)` Create a new `DateTimeFormatterFactory` instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DateTimeFormatter` | `createDateTimeFormatter()` Create a new `DateTimeFormatter` using this factory.
    `DateTimeFormatter` | `createDateTimeFormatter(DateTimeFormatter fallbackFormatter)` Create a new `DateTimeFormatter` using this factory.
    `void` | `setIso(DateTimeFormat.ISO iso)` Set the ISO format used to format date values.
    `void` | `setPattern(String pattern)` Set the pattern to use to format date values.
    `void` | `setStyle(String style)` Set the two characters to use to format date values.
    `void` | `setTimeZone(TimeZone timeZone)` Set the `TimeZone` to normalize the date values into, if any.

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

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

- - ### Constructor Detail

    - #### DateTimeFormatterFactory

          public DateTimeFormatterFactory()

      Create a new `DateTimeFormatterFactory` instance.

    - #### DateTimeFormatterFactory

          public DateTimeFormatterFactory(String pattern)

      Create a new `DateTimeFormatterFactory` instance.
      Parameters:
        `pattern` - the pattern to use to format date values

  - ### Method Detail

    - #### createDateTimeFormatter

          public DateTimeFormatter createDateTimeFormatter()

      Create a new `DateTimeFormatter` using this factory. If no specific `style`, `ISO`, or `pattern` have been defined the `medium date time format` will be used.
      Returns:
        a new date time formatter
      See Also:
        `createDateTimeFormatter(DateTimeFormatter)`

    - #### createDateTimeFormatter

          public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter)

      Create a new `DateTimeFormatter` using this factory. If no specific `style`, `ISO`, or `pattern` have been defined the supplied `fallbackFormatter` will be used.
      Parameters:
        `fallbackFormatter` - the fall-back formatter to use when no specific factory properties have been set (can be `null`).
      Returns:
        a new date time formatter

    - #### setTimeZone

          public void setTimeZone(TimeZone timeZone)

      Set the `TimeZone` to normalize the date values into, if any.
      Parameters:
        `timeZone` - the time zone

    - #### setStyle

          public void setStyle(String style)

      Set the two characters to use to format date values. The first character is used for the date style; the second is for the time style. Supported characters are:
      - 'S' = Small
      - 'M' = Medium
      - 'L' = Long
      - 'F' = Full
      - '-' = Omitted

      This method mimics the styles supported by Joda Time.

      Parameters:
        `style` - two characters from the set {"S", "M", "L", "F", "-"}

    - #### setIso

          public void setIso(DateTimeFormat.ISO iso)

      Set the ISO format used to format date values.
      Parameters:
        `iso` - the ISO format

    - #### setPattern

          public void setPattern(String pattern)

      Set the pattern to use to format date values.
      Parameters:
        `pattern` - the format pattern