All Packages  Class Hierarchy  This Package  Previous  Next  Index

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

java.lang.Object
   |
   +----com.ibm.as400.ui.framework.java.DataFormatter
           |
           +----com.ibm.as400.ui.framework.java.DateFormatter

public class DateFormatter
extends DataFormatter
Formatter for exchanging date values between DataBeans 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:

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 date portions of the Date object returned from parsing are meaningful.

See Also:
DataBean, IllegalUserDataException, DateFormat

Constructor Index

 o DateFormatter()
Constructs a DateFormatter.
 o DateFormatter(int)
Constructs a DateFormatter.

Method Index

 o format(Date)
Format a date based on the current style set for the Date Formatter.
 o format(Object)
Format a date based on the current style set for the Date 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 DateFormatter
 public DateFormatter()
Constructs a DateFormatter. This constructor uses the system default style for date display.

 o DateFormatter
 public DateFormatter(int style)
Constructs a DateFormatter. Accepts a style to be used for date 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 Date 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 Date 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