public class DateTimeFormatterRegistrar extends Object implements FormatterRegistrar
java.time
formatting system for use with Spring.setDateStyle(java.time.format.FormatStyle)
,
setTimeStyle(java.time.format.FormatStyle)
,
setDateTimeStyle(java.time.format.FormatStyle)
,
setUseIsoFormat(boolean)
,
FormatterRegistrar.registerFormatters(org.springframework.format.FormatterRegistry)
,
DateFormatterRegistrar
,
DateTimeFormatterFactoryBean
Constructor and Description |
---|
DateTimeFormatterRegistrar() |
Modifier and Type | Method and Description |
---|---|
void |
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 of
LocalDate 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 of
LocalDateTime 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 of
LocalTime objects. |
void |
setUseIsoFormat(boolean useIsoFormat)
Set whether standard ISO formatting should be applied to all date/time types.
|
public void setUseIsoFormat(boolean useIsoFormat)
If set to "true", the "dateStyle", "timeStyle" and "dateTimeStyle" properties are effectively ignored.
public void setDateStyle(FormatStyle dateStyle)
LocalDate
objects.
Default is FormatStyle.SHORT
.public void setTimeStyle(FormatStyle timeStyle)
LocalTime
objects.
Default is FormatStyle.SHORT
.public void setDateTimeStyle(FormatStyle dateTimeStyle)
LocalDateTime
objects.
Default is FormatStyle.SHORT
.public void setDateFormatter(DateTimeFormatter formatter)
This formatter will be used for the LocalDate
type.
When specified, the dateStyle
and
useIsoFormat
properties will be ignored.
formatter
- the formatter to usesetTimeFormatter(java.time.format.DateTimeFormatter)
,
setDateTimeFormatter(java.time.format.DateTimeFormatter)
public void setTimeFormatter(DateTimeFormatter formatter)
This formatter will be used for the LocalTime
and OffsetTime
types. When specified, the timeStyle
and
useIsoFormat
properties will be ignored.
formatter
- the formatter to usesetDateFormatter(java.time.format.DateTimeFormatter)
,
setDateTimeFormatter(java.time.format.DateTimeFormatter)
public void setDateTimeFormatter(DateTimeFormatter formatter)
This formatter will be used for LocalDateTime
, ZonedDateTime
and OffsetDateTime
types. When specified, the
dateTimeStyle
and
useIsoFormat
properties will be ignored.
formatter
- the formatter to usesetDateFormatter(java.time.format.DateTimeFormatter)
,
setTimeFormatter(java.time.format.DateTimeFormatter)
public void registerFormatters(FormatterRegistry registry)
FormatterRegistrar
registerFormatters
in interface FormatterRegistrar
registry
- the FormatterRegistry instance to use.