Class DateTimeFormatterRegistrar
- java.lang.Object
- org.springframework.format.datetime.standard.DateTimeFormatterRegistrar
- All Implemented Interfaces:
FormatterRegistrar
@UsesJava8 public class DateTimeFormatterRegistrar extends Object implements FormatterRegistrar
Configures the JSR-310java.timeformatting system for use with Spring.- Since:
- 4.0
- Author:
- Juergen Hoeller, Phillip Webb
- See Also:
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 Summary
Constructors Constructor Description DateTimeFormatterRegistrar()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidregisterFormatters(FormatterRegistry registry)Register Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.voidsetDateFormatter(DateTimeFormatter formatter)Set the formatter that will be used for objects representing date values.voidsetDateStyle(FormatStyle dateStyle)Set the default format style ofLocalDateobjects.voidsetDateTimeFormatter(DateTimeFormatter formatter)Set the formatter that will be used for objects representing date and time values.voidsetDateTimeStyle(FormatStyle dateTimeStyle)Set the default format style ofLocalDateTimeobjects.voidsetTimeFormatter(DateTimeFormatter formatter)Set the formatter that will be used for objects representing time values.voidsetTimeStyle(FormatStyle timeStyle)Set the default format style ofLocalTimeobjects.voidsetUseIsoFormat(boolean useIsoFormat)Set whether standard ISO formatting should be applied to all date/time types.
Constructor Detail
DateTimeFormatterRegistrar
public DateTimeFormatterRegistrar()
Method Detail
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
public void setDateStyle(FormatStyle dateStyle)
Set the default format style ofLocalDateobjects. Default isFormatStyle.SHORT.
setTimeStyle
public void setTimeStyle(FormatStyle timeStyle)
Set the default format style ofLocalTimeobjects. Default isFormatStyle.SHORT.
setDateTimeStyle
public void setDateTimeStyle(FormatStyle dateTimeStyle)
Set the default format style ofLocalDateTimeobjects. Default isFormatStyle.SHORT.
setDateFormatter
public void setDateFormatter(DateTimeFormatter formatter)
Set the formatter that will be used for objects representing date values.This formatter will be used for the
LocalDatetype. When specified, thedateStyleanduseIsoFormatproperties will be ignored.- Parameters:
formatter- the formatter to use- See Also:
setTimeFormatter(java.time.format.DateTimeFormatter),setDateTimeFormatter(java.time.format.DateTimeFormatter)
setTimeFormatter
public void setTimeFormatter(DateTimeFormatter formatter)
Set the formatter that will be used for objects representing time values.This formatter will be used for the
LocalTimeandOffsetTimetypes. When specified, thetimeStyleanduseIsoFormatproperties will be ignored.- Parameters:
formatter- the formatter to use- See Also:
setDateFormatter(java.time.format.DateTimeFormatter),setDateTimeFormatter(java.time.format.DateTimeFormatter)
setDateTimeFormatter
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,ZonedDateTimeandOffsetDateTimetypes. When specified, thedateTimeStyleanduseIsoFormatproperties will be ignored.- Parameters:
formatter- the formatter to use- See Also:
setDateFormatter(java.time.format.DateTimeFormatter),setTimeFormatter(java.time.format.DateTimeFormatter)
registerFormatters
public void registerFormatters(FormatterRegistry registry)
Description copied from interface:FormatterRegistrarRegister Formatters and Converters with a FormattingConversionService through a FormatterRegistry SPI.- Specified by:
registerFormattersin interfaceFormatterRegistrar- Parameters:
registry- the FormatterRegistry instance to use.