Class DateFormatterRegistrar

java.lang.Object
org.springframework.format.datetime.DateFormatterRegistrar
All Implemented Interfaces:
FormatterRegistrar

public class DateFormatterRegistrar extends Object implements FormatterRegistrar
Configures basic date formatting for use with Spring, primarily for DateTimeFormat declarations. Applies to fields of type Date, Calendar and long.

Designed for direct instantiation but also exposes the static addDateConverters(ConverterRegistry) utility method for ad-hoc use against any ConverterRegistry instance.

Since:
3.2
Author:
Phillip Webb
See Also:
  • Constructor Details

    • DateFormatterRegistrar

      public DateFormatterRegistrar()
  • Method Details

    • setFormatter

      public void setFormatter(DateFormatter dateFormatter)
      Set a global date formatter to register.

      If not specified, no general formatter for non-annotated Date and Calendar fields will be registered.

    • 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.
    • addDateConverters

      public static void addDateConverters(ConverterRegistry converterRegistry)
      Add date converters to the specified registry.
      Parameters:
      converterRegistry - the registry of converters to add to