|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.ui.framework.java.DataFormatter | +--com.ibm.as400.ui.framework.java.DateFormatter
Formatter for exchanging date values between
DataBean
s and user interface components.
DateFormatter
formats Date
objects and displays as dates
according to current locale, and parses date strings into Date
objects.
If parsing is unsuccessful, an IllegalUserDataException
is thrown.
Dates can be displayed and entered in different styles:
DateFormat.SHORT
Shows a numeric convention (e.g. for US locale "11/29/99")
DateFormat.MEDIUM
Shows numeric day and year, and abbeviated month. (e.g. for US locale "29-Nov-99")
DateFormat.LONG
Same as MEDIUM with non-abbreviated month. (e.g. for US locale "November 29, 1999")
DateFormat.FULL
Same as LONG with day of week shown. (e.g. for US locale "Wednesday, November 29, 1999")
DateFormat.DEFAULT
system style is also available, which is the style used if no
other style is specified.
The default Locale is used for all formatting and parsing.
Only the date portions of the Date
object returned from parsing are meaningful.
DataBean
,
IllegalUserDataException
,
DateFormat
Constructor Summary | |
DateFormatter()
Constructs a DateFormatter . |
|
DateFormatter(int style)
Constructs a DateFormatter with the specified style for date display. |
Method Summary | |
java.lang.String |
format(java.util.Date date)
Format a date based on the current style set for the Date Formatter. |
java.lang.String |
format(java.lang.Object obj)
Format a date based on the current style set for the Date Formatter. |
int |
getStyle()
Gets the style to be used for formatting. |
java.lang.Object |
parse(java.lang.String source)
Parses a string to produce a Date object. |
void |
setStyle(int style)
Sets the style to be used for formatting. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DateFormatter()
DateFormatter
. This constructor
uses the system default style for date display.public DateFormatter(int style)
DateFormatter
with the specified style for date display.
If the style is not valid, an IllegalArgumentException
is thrown.style
- a valid DateFormat
style.Method Detail |
public java.lang.Object parse(java.lang.String source) throws IllegalUserDataException
Date
object. All styles are tried for
parsing. If no style succeeds, then an IllegalUserDataException
is
thrown.parse
in class DataFormatter
source
- the string to be parsedpublic java.lang.String format(java.util.Date date)
date
- a valid Date
object.public java.lang.String format(java.lang.Object obj)
format
in class DataFormatter
obj
- a valid Date
object cast as an object.public void setStyle(int style)
IllegalArgumentException
is thrown.style
- a valid DateFormat
style.public int getStyle()
DateFormat
style.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |