|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.util.WTStandardDateFormat
WTStandardDateFormat
This class provides methods to create display strings
from Date
objects. The methods may take as arguments, not only a Date
,
but also various combinations of format type, format string, Locale and
TimeZone.
There are currently two standard formats defined: "long" and "short". "long" is the default format for methods which do not take a format argument. The format strings are in wt.util.utilResource.rbInfo.
Locale and TimeZone values default to those provided by WTContext methods.
Examples:
WTStandardDateFormat.format(myDate)
WTStandardDateFormat.format(myDate, WTStandardDateFormat.SHORT_STANDARD_DATE_FORMAT)
Date
,
SimpleDateFormat
Field Summary | |
private static Object |
createSync
|
static boolean |
DEBUG
|
static int |
EXPLORER_STANDARD_DATE_FORMAT
Format for the default locale is 'M/dd/yy h:mm a'. |
static int |
EXPLORER_STANDARD_DATE_ONLY_FORMAT
Format for the default locale is 'M/dd/yy'. |
static int |
EXPLORER_STANDARD_TIME_ONLY_FORMAT
Format for the default locale is 'h:mm a'. |
private static Hashtable |
localeFormatCache
|
static int |
LONG_STANDARD_DATE_FORMAT
Format for the default locale is 'yyyy-MM-dd HH:mm:ss z'. |
static int |
LONG_STANDARD_DATE_FORMAT_MINUS_TIME
Format for the default locale is 'yyyy-MM-dd'. |
static int |
LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
Format for the default locale is 'yyyy-MM-dd HH:mm:ss'. |
private static String |
RESOURCE
|
static int |
SHORT_STANDARD_DATE_FORMAT
Format for the default locale is 'dd MMM yy HH:mm'. |
private static String |
versionID
|
static int |
WF_STANDARD_DATE_ONLY_FORMAT
Format for the default locale is 'MM/dd/yyyy'. |
Constructor Summary | |
WTStandardDateFormat()
No-arg constructor. |
Method Summary | |
static String |
format(Date date)
Formats a Date into a date/time string. |
static String |
format(Date date,
int formatType)
Formats a Date into a date/time string. |
static String |
format(Date date,
int formatType,
Locale locale)
Formats a Date into a date/time string. |
static String |
format(Date date,
int formatType,
Locale locale,
TimeZone timeZone)
Formats a Date into a date/time string. |
static String |
format(Date date,
Locale locale)
Formats a Date into a date/time string. |
static String |
format(Date date,
String formatString)
Formats a Date into a date/time string. |
static String |
format(Date date,
String formatString,
Locale locale,
TimeZone timeZone)
Formats a Date into a date/time string. |
static int |
formatTypeFromString(String formatTypeString)
Converts the name of the format type to the constant that it represents. |
private static Hashtable |
getSimpleDateCache(Locale locale)
|
static void |
main(String[] args)
Parse a date and format it for display. |
static Date |
parse(String date)
Parses text from a string in the format LONG_STANDARD_DATE_FORMAT to produce a Date. |
static Date |
parse(String date,
int formatType)
Parses text from a string to produce a Date. |
static Date |
parse(String date,
int formatType,
Locale locale,
TimeZone timeZone)
Parses text from a string to produce a Date. |
static Date |
parse(String date,
Locale locale)
Parses text from a string in the format LONG_STANDARD_DATE_FORMAT to produce a Date. |
static Date |
parse(String date,
String formatString)
Parses text from a string to produce a Date. |
static Date |
parse(String date,
String formatString,
Locale locale,
TimeZone timeZone)
Parses text from a string to produce a Date. |
private static SimpleDateFormat |
popSimpleDateFormat(Locale locale,
String formatString)
|
private static void |
pushSimpleDateFormat(SimpleDateFormat sdf,
Locale locale,
String formatString)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String versionID
private static final String RESOURCE
public static final int LONG_STANDARD_DATE_FORMAT
public static final int SHORT_STANDARD_DATE_FORMAT
public static final int EXPLORER_STANDARD_DATE_FORMAT
public static final int EXPLORER_STANDARD_DATE_ONLY_FORMAT
public static final int EXPLORER_STANDARD_TIME_ONLY_FORMAT
public static final int WF_STANDARD_DATE_ONLY_FORMAT
public static final int LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
public static final int LONG_STANDARD_DATE_FORMAT_MINUS_TIME
public static final boolean DEBUG
private static Hashtable localeFormatCache
private static Object createSync
Constructor Detail |
public WTStandardDateFormat()
Method Detail |
public static int formatTypeFromString(String formatTypeString)
formatTypeString
- The name of the format type. Valid values are:
LONG_STANDARD_DATE_FORMAT
SHORT_STANDARD_DATE_FORMAT
WF_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_DATE_FORMAT
EXPLORER_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_TIME_ONLY_FORMAT
LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
LONG_STANDARD_DATE_FORMAT_MINUS_TIME
public static String format(Date date, String formatString, Locale locale, TimeZone timeZone)
date
- The date to be formatted into a String.formatString
- The format string (see java.text.SimpleDateFormat).locale
- The locale.timeZone
- The given new time zone.
- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
public static String format(Date date, int formatType, Locale locale, TimeZone timeZone)
date
- The date to be formatted into a String.formatType
- The format. Valid values are:
LONG_STANDARD_DATE_FORMAT
SHORT_STANDARD_DATE_FORMAT
WF_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_DATE_FORMAT
EXPLORER_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_TIME_ONLY_FORMAT
LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
LONG_STANDARD_DATE_FORMAT_MINUS_TIME
locale
- The locale whose date format symbols should be used.timeZone
- The given new time zone.
- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
public static String format(Date date, String formatString)
date
- The date to be formatted into a String.formatString
- The format string (see java.text.SimpleDateFormat).
- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
public static String format(Date date, int formatType, Locale locale)
date
- The date to be formatted into a String.formatType
- The format. Valid values are:
LONG_STANDARD_DATE_FORMAT
SHORT_STANDARD_DATE_FORMAT
WF_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_DATE_FORMAT
EXPLORER_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_TIME_ONLY_FORMAT
LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
LONG_STANDARD_DATE_FORMAT_MINUS_TIME
locale
- The locale whose date format symbols should be used.
- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
public static String format(Date date, int formatType)
date
- The date to be formatted into a String.formatType
- The format. Valid values are:
- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
public static String format(Date date, Locale locale)
date
- The date to be formatted into a String.locale
- The locale whose date format symbols should be used.
- Returns:
- The formatted date-time string in
LONG_STANDARD_DATE_FORMAT
format.
Supported API: true
Extendable: false
public static String format(Date date)
date
- The date to be formatted into a String.
- Returns:
- The formatted date-time string in
LONG_STANDARD_DATE_FORMAT
format.
Supported API: true
Extendable: false
public static Date parse(String date, String formatString, Locale locale, TimeZone timeZone) throws ParseException
date
- The string to parse.formatString
- The format string (see java.text.SimpleDateFormat).locale
- The locale.timeZone
- The time zone to use in parsing.
ParseException
- public static Date parse(String date, int formatType, Locale locale, TimeZone timeZone) throws ParseException
date
- The string to parse.formatType
- The format. Valid values are:
LONG_STANDARD_DATE_FORMAT
SHORT_STANDARD_DATE_FORMAT
WF_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_DATE_FORMAT
EXPLORER_STANDARD_DATE_ONLY_FORMAT
EXPLORER_STANDARD_TIME_ONLY_FORMAT
LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
LONG_STANDARD_DATE_FORMAT_MINUS_TIME
locale
- The locale.timeZone
- The time zone to use in parsing.
ParseException
- public static Date parse(String date, String formatString) throws ParseException
date
- The string to parse.formatString
- The format string (see java.text.SimpleDateFormat).
ParseException
- public static Date parse(String date, int formatType) throws ParseException
date
- The string to parse.formatType
- The format. Valid values are:
ParseException
- public static Date parse(String date, Locale locale) throws ParseException
LONG_STANDARD_DATE_FORMAT
to produce a Date.
date
- The string to parse.locale
- The locale.
ParseException
- public static Date parse(String date) throws ParseException
LONG_STANDARD_DATE_FORMAT
to produce a Date.
date
- The string to parse.
ParseException
- private static SimpleDateFormat popSimpleDateFormat(Locale locale, String formatString)
private static void pushSimpleDateFormat(SimpleDateFormat sdf, Locale locale, String formatString)
private static Hashtable getSimpleDateCache(Locale locale)
public static void main(String[] args)
Example Usage: // for current user's locale java wt.util.WTStandardDateFormat "2003-07-21 19:02:23.0" "yyyy-MM-dd HH:mm:ss.S" "MM/dd/yyyy hh:mm:ss a z"// for FRENCH locale java wt.util.WTStandardDateFormat "2003-07-21 19:02:23.0" "yyyy-MM-dd HH:mm:ss.S" "MM/dd/yyyy hh:mm:ss a z" fr
args
- a String[] containing the following elements:
[0] a date
[1] format of passed string to parse into a date
[2] format to use to display parsed date
[3] a locale code
[4] a timezone id
Locale
,
SimpleTimeZone
,
- for formating codes
Supported API: false
Extendable: false
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |