Top Description Inners Fields Constructors Methods
org.springframework.format.datetime

public Class DateFormatterRegistrar

extends Object
implements FormatterRegistrar
Class Inheritance
All Implemented Interfaces
org.springframework.format.FormatterRegistrar
Imports
java.util.Calendar, .Date, org.springframework.core.convert.converter.Converter, .ConverterRegistry, org.springframework.format.FormatterRegistrar, .FormatterRegistry, org.springframework.lang.Nullable, org.springframework.util.Assert

Configures basic date formatting for use with Spring, primarily for org.springframework.format.annotation.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.

Author
Phillip Webb
Since
3.2
See Also
org.springframework.format.datetime.standard.DateTimeFormatterRegistrar, FormatterRegistrar#registerFormatters

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private DateFormatter

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
addDateConverters(ConverterRegistry
the registry of converters to add to
converterRegistry
)

Add date converters to the specified registry.

public void
registerFormatters(FormatterRegistry
the FormatterRegistry instance to use.
registry
)

Implements org.springframework.format.FormatterRegistrar.registerFormatters.

Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.

public void
setFormatter(DateFormatter dateFormatter)

Set a global date formatter to register.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dateFormatterback to summary
private DateFormatter dateFormatter
Annotations
@Nullable

Constructor Detail

DateFormatterRegistrarback to summary
public DateFormatterRegistrar()

Method Detail

addDateConvertersback to summary
public static void addDateConverters(ConverterRegistry converterRegistry)

Add date converters to the specified registry.

Parameters
converterRegistry:ConverterRegistry

the registry of converters to add to

registerFormattersback to summary
public void registerFormatters(FormatterRegistry registry)

Implements org.springframework.format.FormatterRegistrar.registerFormatters.

Doc from org.springframework.format.FormatterRegistrar.registerFormatters.

Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.

Parameters
registry:FormatterRegistry

the FormatterRegistry instance to use.

Annotations
@Override
setFormatterback to summary
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.

org.springframework.format.datetime back to summary

private Class DateFormatterRegistrar.CalendarToDateConverter

extends Object
implements Converter<Calendar, Date>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.datetime.DateFormatterRegistrar.CalendarToDateConverter
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Date
convert(Calendar
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CalendarToDateConverterback to summary
private CalendarToDateConverter()

Method Detail

convertback to summary
public Date convert(Calendar source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Calendar

the source object to convert, which must be an instance of S (never null)

Returns:Date

the converted object, which must be an instance of T (potentially null)

Annotations
@Override
org.springframework.format.datetime back to summary

private Class DateFormatterRegistrar.CalendarToLongConverter

extends Object
implements Converter<Calendar, Long>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.datetime.DateFormatterRegistrar.CalendarToLongConverter
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Long
convert(Calendar
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CalendarToLongConverterback to summary
private CalendarToLongConverter()

Method Detail

convertback to summary
public Long convert(Calendar source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Calendar

the source object to convert, which must be an instance of S (never null)

Returns:Long

the converted object, which must be an instance of T (potentially null)

Annotations
@Override
org.springframework.format.datetime back to summary

private Class DateFormatterRegistrar.DateToCalendarConverter

extends Object
implements Converter<Date, Calendar>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.datetime.DateFormatterRegistrar.DateToCalendarConverter
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Calendar
convert(Date
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DateToCalendarConverterback to summary
private DateToCalendarConverter()

Method Detail

convertback to summary
public Calendar convert(Date source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Date

the source object to convert, which must be an instance of S (never null)

Returns:Calendar

the converted object, which must be an instance of T (potentially null)

Annotations
@Override
org.springframework.format.datetime back to summary

private Class DateFormatterRegistrar.DateToLongConverter

extends Object
implements Converter<Date, Long>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.datetime.DateFormatterRegistrar.DateToLongConverter
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Long
convert(Date
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DateToLongConverterback to summary
private DateToLongConverter()

Method Detail

convertback to summary
public Long convert(Date source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Date

the source object to convert, which must be an instance of S (never null)

Returns:Long

the converted object, which must be an instance of T (potentially null)

Annotations
@Override
org.springframework.format.datetime back to summary

private Class DateFormatterRegistrar.LongToCalendarConverter

extends Object
implements Converter<Long, Calendar>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.datetime.DateFormatterRegistrar.LongToCalendarConverter
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Calendar
convert(Long
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LongToCalendarConverterback to summary
private LongToCalendarConverter()

Method Detail

convertback to summary
public Calendar convert(Long source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Long

the source object to convert, which must be an instance of S (never null)

Returns:Calendar

the converted object, which must be an instance of T (potentially null)

Annotations
@Override
org.springframework.format.datetime back to summary

private Class DateFormatterRegistrar.LongToDateConverter

extends Object
implements Converter<Long, Date>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.datetime.DateFormatterRegistrar.LongToDateConverter
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Date
convert(Long
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LongToDateConverterback to summary
private LongToDateConverter()

Method Detail

convertback to summary
public Date convert(Long source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Long

the source object to convert, which must be an instance of S (never null)

Returns:Date

the converted object, which must be an instance of T (potentially null)

Annotations
@Override