public class DateTimeFormatterFactory extends Object
DateTimeFormatter
.
Formatters will be created using the defined pattern
,
ISO
, and xxxStyle
methods (considered in that order).
createDateTimeFormatter()
,
createDateTimeFormatter(DateTimeFormatter)
,
setPattern(java.lang.String)
,
setIso(org.springframework.format.annotation.DateTimeFormat.ISO)
,
setDateStyle(java.time.format.FormatStyle)
,
setTimeStyle(java.time.format.FormatStyle)
,
setDateTimeStyle(java.time.format.FormatStyle)
,
DateTimeFormatterFactoryBean
Constructor and Description |
---|
DateTimeFormatterFactory()
Create a new
DateTimeFormatterFactory instance. |
DateTimeFormatterFactory(String pattern)
Create a new
DateTimeFormatterFactory instance. |
Modifier and Type | Method and Description |
---|---|
DateTimeFormatter |
createDateTimeFormatter()
Create a new
DateTimeFormatter using this factory. |
DateTimeFormatter |
createDateTimeFormatter(DateTimeFormatter fallbackFormatter)
Create a new
DateTimeFormatter using this factory. |
void |
setDateStyle(FormatStyle dateStyle)
Set the style to use for date types.
|
void |
setDateTimeStyle(FormatStyle dateTimeStyle)
Set the style to use for date and time types.
|
void |
setIso(DateTimeFormat.ISO iso)
Set the ISO format used to format date values.
|
void |
setPattern(String pattern)
Set the pattern to use to format date values.
|
void |
setStylePattern(String style)
Set the two characters to use to format date values, in Joda-Time style.
|
void |
setTimeStyle(FormatStyle timeStyle)
Set the style to use for time types.
|
void |
setTimeZone(TimeZone timeZone)
Set the
TimeZone to normalize the date values into, if any. |
public DateTimeFormatterFactory()
DateTimeFormatterFactory
instance.public DateTimeFormatterFactory(String pattern)
DateTimeFormatterFactory
instance.pattern
- the pattern to use to format date valuespublic void setPattern(String pattern)
pattern
- the format patternpublic void setIso(DateTimeFormat.ISO iso)
iso
- the ISO formatpublic void setDateStyle(FormatStyle dateStyle)
public void setTimeStyle(FormatStyle timeStyle)
public void setDateTimeStyle(FormatStyle dateTimeStyle)
public void setStylePattern(String style)
The first character is used for the date style; the second is for the time style. Supported characters are:
This method mimics the styles supported by Joda-Time. Note that
JSR-310 natively favors FormatStyle
as used for
setDateStyle(java.time.format.FormatStyle)
, setTimeStyle(java.time.format.FormatStyle)
and setDateTimeStyle(java.time.format.FormatStyle)
.
style
- two characters from the set {"S", "M", "L", "F", "-"}public void setTimeZone(TimeZone timeZone)
TimeZone
to normalize the date values into, if any.timeZone
- the time zonepublic DateTimeFormatter createDateTimeFormatter()
DateTimeFormatter
using this factory.
If no specific pattern or style has been defined,
medium date time format
will be used.
createDateTimeFormatter(DateTimeFormatter)
public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter)
DateTimeFormatter
using this factory.
If no specific pattern or style has been defined,
the supplied fallbackFormatter
will be used.
fallbackFormatter
- the fall-back formatter to use
when no specific factory properties have been set