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

public Class DateTimeFormatterRegistrar

extends Object
implements FormatterRegistrar
Class Inheritance
All Implemented Interfaces
org.springframework.format.FormatterRegistrar
Imports
java.time.Duration, .Instant, .LocalDate, .LocalDateTime, .LocalTime, .Month, .MonthDay, .OffsetDateTime, .OffsetTime, .Period, .Year, .YearMonth, .ZonedDateTime, java.time.format.DateTimeFormatter, .FormatStyle, java.util.EnumMap, .Map, org.springframework.format.FormatterRegistrar, .FormatterRegistry, org.springframework.format.annotation.DateTimeFormat.ISO

Configures the JSR-310 java.time formatting system for use with Spring.
Authors
Juergen Hoeller, Phillip Webb
Since
4.0
See Also
setDateStyle, setTimeStyle, setDateTimeStyle, setUseIsoFormat, org.springframework.format.FormatterRegistrar#registerFormatters, org.springframework.format.datetime.DateFormatterRegistrar

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final Map<DateTimeFormatterRegistrar.Type, DateTimeFormatterFactory>
factories

Factories used when specific formatters have not been specified.

private final Map<DateTimeFormatterRegistrar.Type, DateTimeFormatter>
formatters

User-defined formatters.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private DateTimeFormatter
private DateTimeFormatter
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
setDateFormatter(DateTimeFormatter
the formatter to use
formatter
)

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

public void
setDateStyle(FormatStyle dateStyle)

Set the default format style of java.time.LocalDate objects.

public void
setDateTimeFormatter(DateTimeFormatter
the formatter to use
formatter
)

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

public void
setDateTimeStyle(FormatStyle dateTimeStyle)

Set the default format style of java.time.LocalDateTime objects.

public void
setTimeFormatter(DateTimeFormatter
the formatter to use
formatter
)

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

public void
setTimeStyle(FormatStyle timeStyle)

Set the default format style of java.time.LocalTime objects.

public void
setUseIsoFormat(boolean useIsoFormat)

Set whether standard ISO formatting should be applied to all date/time types.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoriesback to summary
private final Map<DateTimeFormatterRegistrar.Type, DateTimeFormatterFactory> factories

Factories used when specific formatters have not been specified.

formattersback to summary
private final Map<DateTimeFormatterRegistrar.Type, DateTimeFormatter> formatters

User-defined formatters.

Constructor Detail

DateTimeFormatterRegistrarback to summary
public DateTimeFormatterRegistrar()

Method Detail

getFallbackFormatterback to summary
private DateTimeFormatter getFallbackFormatter(DateTimeFormatterRegistrar.Type type)
getFormatterback to summary
private DateTimeFormatter getFormatter(DateTimeFormatterRegistrar.Type type)
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
setDateFormatterback to summary
public void setDateFormatter(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:DateTimeFormatter

the formatter to use

See Also
setTimeFormatter, setDateTimeFormatter
setDateStyleback to summary
public void setDateStyle(FormatStyle dateStyle)

Set the default format style of java.time.LocalDate objects. Default is java.time.format.FormatStyle#SHORT.

setDateTimeFormatterback to summary
public void setDateTimeFormatter(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:DateTimeFormatter

the formatter to use

See Also
setDateFormatter, setTimeFormatter
setDateTimeStyleback to summary
public void setDateTimeStyle(FormatStyle dateTimeStyle)

Set the default format style of java.time.LocalDateTime objects. Default is java.time.format.FormatStyle#SHORT.

setTimeFormatterback to summary
public void setTimeFormatter(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:DateTimeFormatter

the formatter to use

See Also
setDateFormatter, setDateTimeFormatter
setTimeStyleback to summary
public void setTimeStyle(FormatStyle timeStyle)

Set the default format style of java.time.LocalTime objects. Default is java.time.format.FormatStyle#SHORT.

setUseIsoFormatback to summary
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.

org.springframework.format.datetime.standard back to summary

private final Enum DateTimeFormatterRegistrar.Type

extends Enum<DateTimeFormatterRegistrar.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final DateTimeFormatterRegistrar.Type
public static final DateTimeFormatterRegistrar.Type
public static final DateTimeFormatterRegistrar.Type

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static DateTimeFormatterRegistrar.Type
public static DateTimeFormatterRegistrar.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DATEback to summary
public static final DateTimeFormatterRegistrar.Type DATE
DATE_TIMEback to summary
public static final DateTimeFormatterRegistrar.Type DATE_TIME
TIMEback to summary
public static final DateTimeFormatterRegistrar.Type TIME

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static DateTimeFormatterRegistrar.Type valueOf(String name)
valuesback to summary
public static DateTimeFormatterRegistrar.Type[] values()