com.ibm.websphere.i18n.localizabletext
Class LocalizableTextDateTimeArgument
java.lang.Object
|
+--com.ibm.websphere.i18n.localizabletext.LocalizableTextDateTimeArgument
- All Implemented Interfaces:
- Localizable, LocalizableTextLTZ, java.io.Serializable
- public class LocalizableTextDateTimeArgument
- extends java.lang.Object
- implements LocalizableTextLTZ, java.io.Serializable
The LocalizableTextDateTimeArgument class processes a contained Date object and returns a translated string.
Translation is done using a passed Locale and TimeZone. The returned string can be for any combination of
the "LocalizableTextDateTimeArgument dateTimeStyle" constants, plus the "java.text.DateFormat style" constants.
The class is intended to be used as an argument in the LocalizableTextFormatter class
which calls this class's format method passing the desired Locale and TimeZone. To use this class
construct it passing all the required parameters and place it in the argument array of a
LocalizableTextFormatter. When the LocalizableTextFormatter is formatted, it will then call the format method on this class.
The returned date/time
string from this class will substituted in the argument array at the same index of the LocalizableTextFormatter.
This class will output the desired Locale and TimeZone when used in an distributed environment.
Output Examples:
Below are some examples of returned strings when using various inputs with a Date object
created from a GregorianCalendar with year=2000, month=1, day=22, hour=14, minute=38, second=45
Note: The example string outputs may be dependent on the JDK level.
LocalizableTextDateTimeArgument.DATEANDTIME, DateFormat.FULL, English, CST
Tuesday, February 22, 2000 2:38:45 PM CST
LocalizableTextDateTimeArgument.DATEANDTIME, DateFormat.LONG, English, CST
February 22, 2000 2:38:45 PM CST
LocalizableTextDateTimeArgument.DATEANDTIME,DateFormat.MEDIUM, English, CST
Feb 22, 2000 2:38:45 PM
LocalizableTextDateTimeArgument.DATEANDTIME, DateFormat.SHORT, English, CST
2/22/00 2:38 PM
LocalizableTextDateTimeArgument.DATEANDTIME, DateFormat.DEFAULT, English, CST
Feb 22, 2000 2:38:45 PM
LocalizableTextDateTimeArgument.TIMEANDDATE, DateFormat.FULL, English, CST
2:38:45 PM CST Tuesday, February 22, 2000
LocalizableTextDateTimeArgument.TIME, DateFormat.FULL, English, CST
2:38:45 PM CST
LocalizableTextDateTimeArgument.DATE, DateFormat.FULL, English, CST
Tuesday, February 22, 2000
LocalizableTextDateTimeArgument.DATEANDTIME, DateFormat.FULL, English, PST
Tuesday, February 22, 2000 12:38:45 PM PST
LocalizableTextDateTimeArgument.DATEANDTIME, DateFormat.FULL, French, CST
mardi 22 février 2000 14 h 38 GMT-06:00
- See Also:
- Serialized Form
Field Summary |
static int |
DATE
Date constant for dateTimeStyle parameter on constructor. |
static int |
DATEANDTIME
Date & Time constant for dateTimeStyle parameter on constructor. |
static int |
TIME
Time constant for dateTimeStyle parameter on constructor. |
static int |
TIMEANDDATE
Time & Date constant for dateTimeStyle parameter on constructor. |
Method Summary |
boolean |
equals(java.lang.Object param)
|
java.lang.String |
format(java.util.Locale locale,
java.util.TimeZone timeZone)
Format the contained Date object with the styles passed to the constructor. |
int |
hashCode()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
DATE
public static final int DATE
- Date constant for dateTimeStyle parameter on constructor. Return a date string.
TIME
public static final int TIME
- Time constant for dateTimeStyle parameter on constructor. Return a time string.
DATEANDTIME
public static final int DATEANDTIME
- Date & Time constant for dateTimeStyle parameter on constructor. Return a date and time string.
TIMEANDDATE
public static final int TIMEANDDATE
- Time & Date constant for dateTimeStyle parameter on constructor. Return a time and date string.
LocalizableTextDateTimeArgument
public LocalizableTextDateTimeArgument(java.util.Date date,
int dateTimeStyle,
int dateFormatStyle)
- Parameters:
date
- The Date object to be processed.dateTimeStyle
- The Date object will be processed as:
LocalizableTextDateTimeArgument.DATE or
LocalizableTextDateTimeArgument.TIME or
LocalizableTextDateTimeArgument.DATEANDTIME or
LocalizableTextDateTimeArgument.TIMEANDDATE
Refer to this class's constants for documentation on these styles.style
- The style of date/time string to be processed as:
java.text.DateFormat.FULL or
java.text.DateFormat.LONG or
java.text.DateFormat.MEDIUM or
java.text.DateFormat.SHORT or
java.text.DateFormat.DEFAULT
Refer to java.text.DateFormat constants for documentation on these styles.
equals
public boolean equals(java.lang.Object param)
- Overrides:
equals
in class java.lang.Object
format
public java.lang.String format(java.util.Locale locale,
java.util.TimeZone timeZone)
throws java.lang.IllegalArgumentException
- Format the contained Date object with the styles passed to the constructor.
This method is called when a format() is done on the
containing LocalizableTextFormatter object.
- Specified by:
format
in interface LocalizableTextLTZ
- Parameters:
locale
- The locale to be used to format the Date object. The locale is
determined by the LocalizableTextFormattertimeZone
- The time zone to be used to format the Date object. The time zone is
determined by the LocalizableTextFormatter- Returns:
- String - The language specific date and/or time string
- Throws:
java.lang.IllegalArgumentException
- If one of the four predefined dateTimeStyle's are not passed
to the constructor, an IllegalArgumentException will be thrown when the argument is formatted.
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object