Class JodaTimeFormatterRegistrar
- java.lang.Object
- org.springframework.format.datetime.joda.JodaTimeFormatterRegistrar
- All Implemented Interfaces:
FormatterRegistrar
public class JodaTimeFormatterRegistrar extends Object implements FormatterRegistrar
Configures Joda-Time's formatting system for use with Spring.NOTE: Spring's Joda-Time support requires Joda-Time 2.x, as of Spring 4.0.
- Since:
- 3.1
- Author:
- Keith Donald, Juergen Hoeller, Phillip Webb
- See Also:
setDateStyle(java.lang.String)
,setTimeStyle(java.lang.String)
,setDateTimeStyle(java.lang.String)
,setUseIsoFormat(boolean)
,FormatterRegistrar.registerFormatters(org.springframework.format.FormatterRegistry)
,DateFormatterRegistrar
,DateTimeFormatterFactoryBean
Constructor Summary
Constructors Constructor Description JodaTimeFormatterRegistrar()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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(String dateStyle)
Set the default format style of JodaLocalDate
objects.void
setDateTimeFormatter(DateTimeFormatter formatter)
Set the formatter that will be used for objects representing date and time values.void
setDateTimeStyle(String dateTimeStyle)
Set the default format style of JodaLocalDateTime
andDateTime
objects, as well as JDKDate
andCalendar
objects.void
setTimeFormatter(DateTimeFormatter formatter)
Set the formatter that will be used for objects representing time values.void
setTimeStyle(String timeStyle)
Set the default format style of JodaLocalTime
objects.void
setUseIsoFormat(boolean useIsoFormat)
Set whether standard ISO formatting should be applied to all date/time types.
Constructor Detail
JodaTimeFormatterRegistrar
public JodaTimeFormatterRegistrar()
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(String dateStyle)
Set the default format style of JodaLocalDate
objects. Default isDateTimeFormat.shortDate()
.
setTimeStyle
public void setTimeStyle(String timeStyle)
Set the default format style of JodaLocalTime
objects. Default isDateTimeFormat.shortTime()
.
setDateTimeStyle
public void setDateTimeStyle(String dateTimeStyle)
Set the default format style of JodaLocalDateTime
andDateTime
objects, as well as JDKDate
andCalendar
objects. Default isDateTimeFormat.shortDateTime()
.
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
LocalDate
type. When specified thedateStyle
anduseIsoFormat
properties will be ignored.- Parameters:
formatter
- the formatter to use- Since:
- 3.2
- See Also:
setTimeFormatter(org.joda.time.format.DateTimeFormatter)
,setDateTimeFormatter(org.joda.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
LocalTime
type. When specified thetimeStyle
anduseIsoFormat
properties will be ignored.- Parameters:
formatter
- the formatter to use- Since:
- 3.2
- See Also:
setDateFormatter(org.joda.time.format.DateTimeFormatter)
,setDateTimeFormatter(org.joda.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
,ReadableInstant
,Date
andCalendar
types. When specified thedateTimeStyle
anduseIsoFormat
properties will be ignored.- Parameters:
formatter
- the formatter to use- Since:
- 3.2
- See Also:
setDateFormatter(org.joda.time.format.DateTimeFormatter)
,setTimeFormatter(org.joda.time.format.DateTimeFormatter)
registerFormatters
public void registerFormatters(FormatterRegistry registry)
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.