Class DateTimeFormatterRegistrar
java.lang.Object
org.springframework.format.datetime.standard.DateTimeFormatterRegistrar
- All Implemented Interfaces:
FormatterRegistrar
Configures the JSR-310
java.time
formatting system for use with Spring.- Since:
- 4.0
- Author:
- Juergen Hoeller, Phillip Webb
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
registerFormatters
(FormatterRegistry registry) Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.void
setDateFormatter
(DateTimeFormatter formatter) Set the formatter that will be used for objects representing date values.void
setDateStyle
(FormatStyle dateStyle) Set the default format style ofLocalDate
objects.void
setDateTimeFormatter
(DateTimeFormatter formatter) Set the formatter that will be used for objects representing date and time values.void
setDateTimeStyle
(FormatStyle dateTimeStyle) Set the default format style ofLocalDateTime
objects.void
setTimeFormatter
(DateTimeFormatter formatter) Set the formatter that will be used for objects representing time values.void
setTimeStyle
(FormatStyle timeStyle) Set the default format style ofLocalTime
objects.void
setUseIsoFormat
(boolean useIsoFormat) Set whether standard ISO formatting should be applied to all date/time types.
-
Constructor Details
-
DateTimeFormatterRegistrar
public DateTimeFormatterRegistrar()
-
-
Method Details
-
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
Set the default format style ofLocalDate
objects.Default is
FormatStyle.SHORT
. -
setTimeStyle
Set the default format style ofLocalTime
objects.Default is
FormatStyle.SHORT
. -
setDateTimeStyle
Set the default format style ofLocalDateTime
objects.Default is
FormatStyle.SHORT
. -
setDateFormatter
Set the formatter that will be used for objects representing date values.This formatter will be used for the
LocalDate
type. When specified, thedateStyle
anduseIsoFormat
properties will be ignored.- Parameters:
formatter
- the formatter to use- See Also:
-
setTimeFormatter
Set the formatter that will be used for objects representing time values.This formatter will be used for the
LocalTime
andOffsetTime
types. When specified, thetimeStyle
anduseIsoFormat
properties will be ignored.- Parameters:
formatter
- the formatter to use- See Also:
-
setDateTimeFormatter
Set the formatter that will be used for objects representing date and time values.This formatter will be used for
LocalDateTime
,ZonedDateTime
, andOffsetDateTime
types. When specified, thedateTimeStyle
anduseIsoFormat
properties will be ignored.- Parameters:
formatter
- the formatter to use- See Also:
-
registerFormatters
Description copied from interface:FormatterRegistrar
Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.- Specified by:
registerFormatters
in interfaceFormatterRegistrar
- Parameters:
registry
- the FormatterRegistry instance to use.
-