All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.ui.framework.java.TimeFormatter

java.lang.Object
   |
   +----com.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:

The 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.

See Also:
DataBean, IllegalUserDataException, DateFormat

Constructor Index

 o TimeFormatter()
Constructs a TimeFormatter.
 o TimeFormatter(int)
Constructs a TimeFormatter.

Method Index

 o format(Date)
Format a date based on the current style set for the Time Formatter.
 o format(Object)
Format a date based on the current style set for the Time Formatter.
 o getStyle()
Gets the style to be used for formatting.
 o parse(String)
Parses a string to produce a Date object.
 o setStyle(int)
Sets the style to be used for formatting.

Constructors

 o TimeFormatter
 public TimeFormatter()
Constructs a TimeFormatter. This constructor uses the system default style for time display.

 o TimeFormatter
 public TimeFormatter(int style)
Constructs a TimeFormatter. Accepts a style to be used for time display. If the style is not valid, an IllegalArgumentException/code> is thrown.

Parameters:
style - a valid DateFormat style.

Methods

 o parse
 public Object parse(String source) throws IllegalUserDataException
Parses a string to produce a Date object. All styles are tried for parsing. If no style succeeds, then an IllegalUserDataException is thrown.

Parameters:
source - the string to be parsed
Returns:
the Date obtained by parsing the string
Overrides:
parse in class DataFormatter
 o format
 public String format(Date date)
Format a date based on the current style set for the Time Formatter.

Parameters:
date - a valid Date object.
 o format
 public String format(Object obj)
Format a date based on the current style set for the Time Formatter. Throws an IllegalArgumentException if the object is not an instance of Date.

Parameters:
obj - a valid Date object cast as an object.
Overrides:
format in class DataFormatter
 o setStyle
 public void setStyle(int style)
Sets the style to be used for formatting. If the style is not valid, an IllegalArgumentException/code> is thrown.

Parameters:
style - a valid DateFormat style.
 o getStyle
 public int getStyle()
Gets the style to be used for formatting.

Returns:
a DateFormat style.

All Packages  Class Hierarchy  This Package  Previous  Next  Index