|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.as400.ui.framework.java.DataFormatter
com.ibm.as400.ui.framework.java.TimeFormatter
public class TimeFormatter extends DataFormatter
Formatter for exchanging time values between
DataBeans and user interface components.
TimeFormatter formats Date objects and displays as times
according to current locale, and parses time strings into Date objects.
If parsing is unsuccessful, an IllegalUserDataException is thrown.
Times can be displayed and entered in different styles:
DateFormat.SHORT Shows hours and minutes (e.g. for US locale "3:06 PM")
DateFormat.MEDIUM Shows hours, minutes and seconds (e.g. for US locale "3:06:59 PM")
DateFormat.LONG Shows hours, minutes, seconds, and time zone (e.g. for US locale "3:06:59 PM CDT")
DateFormat.FULL Same as LONG with words. (e.g. for US locale "3:06:59 o'clock PM CDT")
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 time portions of the Date object returned from parsing are meaningful.
DataBean,
IllegalUserDataException,
DateFormat| Constructor and Description |
|---|
TimeFormatter()
Constructs a TimeFormatter. |
TimeFormatter(int style)
Constructs a TimeFormatter with the specified style for time display. |
| Modifier and Type | Method and Description |
|---|---|
String |
format(Date date)
Format a date based on the current style set for the Time Formatter. |
String |
format(Object obj)
Format a date based on the current style set for the Time Formatter. |
int |
getStyle()
Gets the style to be used for formatting. |
Object |
parse(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 TimeFormatter()
TimeFormatter. This constructor
uses the system default style for time display.
public TimeFormatter(int style)
TimeFormatter with the specified style for time display.
If the style is not valid, an IllegalArgumentException is thrown.
style - a valid DateFormat style.| Method Detail |
|---|
public Object parse(String source)
throws IllegalUserDataException
Date object. All styles are tried for
parsing. If no style succeeds, then an IllegalUserDataException is
thrown.
parse in class DataFormattersource - the string to be parsedIllegalUserDataExceptionpublic String format(Date date)
date - a valid Date object.public String format(Object obj)
format in class DataFormatterobj - 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: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||