Package org.springframework.format.datetime

# 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:
  - `DateTimeFormatterRegistrar`
  - `FormatterRegistrar.registerFormatters(org.springframework.format.FormatterRegistry)`

## Constructor Summary

Constructors
Constructor
Description
`DateFormatterRegistrar()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`addDateConverters(org.springframework.core.convert.converter.ConverterRegistry converterRegistry)`
Add date converters to the specified registry.
`void`
`registerFormatters(FormatterRegistry registry)`
Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.
`void`
`setFormatter(DateFormatter dateFormatter)`
Set a global date formatter to register.

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

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

## 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(org.springframework.core.convert.converter.ConverterRegistry converterRegistry)
Add date converters to the specified registry.

Parameters:
  `converterRegistry` - the registry of converters to add to