public class JodaTimeFormatterRegistrar extends java.lang.Object implements FormatterRegistrar
NOTE: Spring's Joda-Time support requires Joda-Time 2.x, as of Spring 4.0.
setDateStyle(java.lang.String)
,
setTimeStyle(java.lang.String)
,
setDateTimeStyle(java.lang.String)
,
setUseIsoFormat(boolean)
,
FormatterRegistrar.registerFormatters(org.springframework.format.FormatterRegistry)
,
DateFormatterRegistrar
,
DateTimeFormatterFactoryBean
Modifier and Type | Class and Description |
---|---|
private static class |
JodaTimeFormatterRegistrar.Type |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<JodaTimeFormatterRegistrar.Type,DateTimeFormatterFactory> |
factories
Factories used when specific formatters have not been specified.
|
private java.util.Map<JodaTimeFormatterRegistrar.Type,DateTimeFormatter> |
formatters
User defined formatters.
|
Constructor and Description |
---|
JodaTimeFormatterRegistrar() |
Modifier and Type | Method and Description |
---|---|
private void |
addFormatterForFields(FormatterRegistry registry,
Printer<?> printer,
Parser<?> parser,
java.lang.Class<?>... fieldTypes) |
private DateTimeFormatter |
getFallbackFormatter(JodaTimeFormatterRegistrar.Type type) |
private DateTimeFormatter |
getFormatter(JodaTimeFormatterRegistrar.Type type) |
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(java.lang.String dateStyle)
Set the default format style of Joda
LocalDate objects. |
void |
setDateTimeFormatter(DateTimeFormatter formatter)
Set the formatter that will be used for objects representing date and time values.
|
void |
setDateTimeStyle(java.lang.String dateTimeStyle)
Set the default format style of Joda
LocalDateTime and DateTime objects,
as well as JDK Date and Calendar objects. |
void |
setTimeFormatter(DateTimeFormatter formatter)
Set the formatter that will be used for objects representing time values.
|
void |
setTimeStyle(java.lang.String timeStyle)
Set the default format style of Joda
LocalTime objects. |
void |
setUseIsoFormat(boolean useIsoFormat)
Set whether standard ISO formatting should be applied to all date/time types.
|
private final java.util.Map<JodaTimeFormatterRegistrar.Type,DateTimeFormatter> formatters
private final java.util.Map<JodaTimeFormatterRegistrar.Type,DateTimeFormatterFactory> factories
public void setUseIsoFormat(boolean useIsoFormat)
If set to "true", the "dateStyle", "timeStyle" and "dateTimeStyle" properties are effectively ignored.
public void setDateStyle(java.lang.String dateStyle)
LocalDate
objects.
Default is DateTimeFormat#shortDate()
.public void setTimeStyle(java.lang.String timeStyle)
LocalTime
objects.
Default is DateTimeFormat#shortTime()
.public void setDateTimeStyle(java.lang.String dateTimeStyle)
LocalDateTime
and DateTime
objects,
as well as JDK Date
and Calendar
objects.
Default is DateTimeFormat#shortDateTime()
.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(DateTimeFormatter)
,
setDateTimeFormatter(DateTimeFormatter)
public void setTimeFormatter(DateTimeFormatter formatter)
This formatter will be used for the LocalTime
type. When specified
the timeStyle
and
useIsoFormat
properties will be ignored.
formatter
- the formatter to usesetDateFormatter(DateTimeFormatter)
,
setDateTimeFormatter(DateTimeFormatter)
public void setDateTimeFormatter(DateTimeFormatter formatter)
This formatter will be used for LocalDateTime
, ReadableInstant
,
Date
and Calendar
types. When specified
the dateTimeStyle
and
useIsoFormat
properties will be ignored.
formatter
- the formatter to usesetDateFormatter(DateTimeFormatter)
,
setTimeFormatter(DateTimeFormatter)
public void registerFormatters(FormatterRegistry registry)
FormatterRegistrar
registerFormatters
in interface FormatterRegistrar
registry
- the FormatterRegistry instance to use.private DateTimeFormatter getFormatter(JodaTimeFormatterRegistrar.Type type)
private DateTimeFormatter getFallbackFormatter(JodaTimeFormatterRegistrar.Type type)
private void addFormatterForFields(FormatterRegistry registry, Printer<?> printer, Parser<?> parser, java.lang.Class<?>... fieldTypes)