|
|||||||||
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
Constructor Summary | |
---|---|
DateFormatter()
Create a new default DateFormatter. |
|
DateFormatter(String pattern)
Create a new DateFormatter for the given date pattern. |
Method Summary | |
---|---|
protected DateFormat |
getDateFormat(Locale locale)
|
Date |
parse(String text,
Locale locale)
Parse a text String to produce a T. |
String |
print(Date date,
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(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(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 |
Constructor Detail |
---|
public DateFormatter()
public DateFormatter(String pattern)
Method Detail |
---|
public void setPattern(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(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 String print(Date date, Locale locale)
Printer
print
in interface Printer<Date>
date
- the instance to printlocale
- the current user locale
public Date parse(String text, Locale locale) throws ParseException
Parser
parse
in interface Parser<Date>
text
- the text stringlocale
- the current user locale
ParseException
- when a parse exception occurs in a java.text parsing libraryprotected DateFormat getDateFormat(Locale locale)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |