public class DateFormatter extends java.lang.Object implements Formatter<java.util.Date>
Date
types.
Allows the configuration of an explicit date pattern and locale.SimpleDateFormat
Constructor and Description |
---|
DateFormatter()
Create a new default DateFormatter.
|
DateFormatter(java.lang.String pattern)
Create a new DateFormatter for the given date pattern.
|
Modifier and Type | Method and Description |
---|---|
protected java.text.DateFormat |
getDateFormat(java.util.Locale locale) |
java.util.Date |
parse(java.lang.String text,
java.util.Locale locale)
Parse a text String to produce a T.
|
java.lang.String |
print(java.util.Date date,
java.util.Locale locale)
Print the object of type T for display.
|
void |
setIso(DateTimeFormat.ISO iso)
Set the ISO format used for this date.
|
void |
setLenient(boolean lenient)
Specify whether or not parsing is to be lenient.
|
void |
setPattern(java.lang.String pattern)
Set the pattern to use to format date values.
|
void |
setStyle(int style)
Set the style to use to format date values.
|
void |
setStylePattern(java.lang.String stylePattern)
Set the two character to use to format date values.
|
void |
setTimeZone(java.util.TimeZone timeZone)
Set the TimeZone to normalize the date values into, if any.
|
public DateFormatter()
public DateFormatter(java.lang.String pattern)
public void setPattern(java.lang.String pattern)
If not specified, DateFormat's default style will be used.
public void setIso(DateTimeFormat.ISO iso)
iso
- the DateTimeFormat.ISO
formatpublic void setStyle(int style)
If not specified, DateFormat's default style will be used.
DateFormat.DEFAULT
,
DateFormat.SHORT
,
DateFormat.MEDIUM
,
DateFormat.LONG
,
DateFormat.FULL
public void setStylePattern(java.lang.String stylePattern)
stylePattern
- two characters from the set {"S", "M", "L", "F", "-"}public void setTimeZone(java.util.TimeZone timeZone)
public void setLenient(boolean lenient)
With lenient parsing, the parser may allow inputs that do not precisely match the format. With strict parsing, inputs must match the format exactly.
public java.lang.String print(java.util.Date date, java.util.Locale locale)
Printer
public java.util.Date parse(java.lang.String text, java.util.Locale locale) throws java.text.ParseException
Parser
protected java.text.DateFormat getDateFormat(java.util.Locale locale)