org.springframework.format.datetime.standard

## Class DateTimeFormatterRegistrar

- java.lang.Object
- - org.springframework.format.datetime.standard.DateTimeFormatterRegistrar

- All Implemented Interfaces:
    FormatterRegistrar

      public class DateTimeFormatterRegistrar
      extends Object
      implements FormatterRegistrar

  Configures the JSR-310 `java.time` formatting system for use with Spring.
  Since:
    4.0
  Author:
    Juergen Hoeller, Phillip Webb
  See Also:
    `setDateStyle(java.time.format.FormatStyle)`, `setTimeStyle(java.time.format.FormatStyle)`, `setDateTimeStyle(java.time.format.FormatStyle)`, `setUseIsoFormat(boolean)`, `FormatterRegistrar.registerFormatters(org.springframework.format.FormatterRegistry)`, `DateFormatterRegistrar`, `DateTimeFormatterFactoryBean`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DateTimeFormatterRegistrar()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `registerFormatters(FormatterRegistry registry)` Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.
    `void` | `setDateFormatter(java.time.format.DateTimeFormatter formatter)` Set the formatter that will be used for objects representing date values.
    `void` | `setDateStyle(java.time.format.FormatStyle dateStyle)` Set the default format style of `LocalDate` objects.
    `void` | `setDateTimeFormatter(java.time.format.DateTimeFormatter formatter)` Set the formatter that will be used for objects representing date and time values.
    `void` | `setDateTimeStyle(java.time.format.FormatStyle dateTimeStyle)` Set the default format style of `LocalDateTime` objects.
    `void` | `setTimeFormatter(java.time.format.DateTimeFormatter formatter)` Set the formatter that will be used for objects representing time values.
    `void` | `setTimeStyle(java.time.format.FormatStyle timeStyle)` Set the default format style of `LocalTime` objects.
    `void` | `setUseIsoFormat(boolean useIsoFormat)` Set whether standard ISO formatting should be applied to all date/time types.

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

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

- - ### Constructor Detail

    - #### DateTimeFormatterRegistrar

          public DateTimeFormatterRegistrar()

  - ### Method Detail

    - #### setUseIsoFormat

          public void setUseIsoFormat(boolean useIsoFormat)

      Set whether standard ISO formatting should be applied to all date/time types. Default is "false" (no).

      If set to "true", the "dateStyle", "timeStyle" and "dateTimeStyle" properties are effectively ignored.

    - #### setDateStyle

          public void setDateStyle(java.time.format.FormatStyle dateStyle)

      Set the default format style of `LocalDate` objects. Default is `FormatStyle.SHORT`.

    - #### setTimeStyle

          public void setTimeStyle(java.time.format.FormatStyle timeStyle)

      Set the default format style of `LocalTime` objects. Default is `FormatStyle.SHORT`.

    - #### setDateTimeStyle

          public void setDateTimeStyle(java.time.format.FormatStyle dateTimeStyle)

      Set the default format style of `LocalDateTime` objects. Default is `FormatStyle.SHORT`.

    - #### setDateFormatter

          public void setDateFormatter(java.time.format.DateTimeFormatter formatter)

      Set the formatter that will be used for objects representing date values.

      This formatter will be used for the `LocalDate` type. When specified, the `dateStyle` and `useIsoFormat` properties will be ignored.

      Parameters:
        `formatter` - the formatter to use
      See Also:
        `setTimeFormatter(java.time.format.DateTimeFormatter)`, `setDateTimeFormatter(java.time.format.DateTimeFormatter)`

    - #### setTimeFormatter

          public void setTimeFormatter(java.time.format.DateTimeFormatter formatter)

      Set the formatter that will be used for objects representing time values.

      This formatter will be used for the `LocalTime` and `OffsetTime` types. When specified, the `timeStyle` and `useIsoFormat` properties will be ignored.

      Parameters:
        `formatter` - the formatter to use
      See Also:
        `setDateFormatter(java.time.format.DateTimeFormatter)`, `setDateTimeFormatter(java.time.format.DateTimeFormatter)`

    - #### setDateTimeFormatter

          public void setDateTimeFormatter(java.time.format.DateTimeFormatter formatter)

      Set the formatter that will be used for objects representing date and time values.

      This formatter will be used for `LocalDateTime`, `ZonedDateTime` and `OffsetDateTime` types. When specified, the `dateTimeStyle` and `useIsoFormat` properties will be ignored.

      Parameters:
        `formatter` - the formatter to use
      See Also:
        `setDateFormatter(java.time.format.DateTimeFormatter)`, `setTimeFormatter(java.time.format.DateTimeFormatter)`

    - #### registerFormatters

          public void registerFormatters(FormatterRegistry registry)

      Description copied from interface: `FormatterRegistrar`
      Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.
      Specified by:
        `registerFormatters` in interface `FormatterRegistrar`
      Parameters:
        `registry` - the FormatterRegistry instance to use.