|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.format.datetime.DateFormatter
public class DateFormatter
A formatter for Date
types.
Allows the configuration of an explicit date pattern and locale.
SimpleDateFormat
Field Summary | |
---|---|
private boolean |
lenient
|
private java.lang.String |
pattern
|
private int |
style
|
private java.util.TimeZone |
timeZone
|
Constructor Summary | |
---|---|
DateFormatter()
Create a new default DateFormatter. |
|
DateFormatter(java.lang.String pattern)
Create a new DateFormatter for the given date pattern. |
Method Summary | |
---|---|
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 |
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 |
setTimeZone(java.util.TimeZone timeZone)
Set the TimeZone to normalize the date values into, if any. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String pattern
private int style
private java.util.TimeZone timeZone
private boolean lenient
Constructor Detail |
---|
public DateFormatter()
public DateFormatter(java.lang.String pattern)
Method Detail |
---|
public void setPattern(java.lang.String pattern)
If not specified, DateFormat's default style will be used.
public 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 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
print
in interface Printer<java.util.Date>
date
- the instance to printlocale
- the current user locale
public java.util.Date parse(java.lang.String text, java.util.Locale locale) throws java.text.ParseException
Parser
parse
in interface Parser<java.util.Date>
text
- the text stringlocale
- the current user locale
java.text.ParseException
- when a parse exception occurs in a java.text parsing libraryprotected java.text.DateFormat getDateFormat(java.util.Locale locale)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |