Package wt.util
Class WTStandardDateFormat
java.lang.Object
wt.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)
- returns: "1998-05-28 14:22:35 CST"
WTStandardDateFormat.format(myDate, WTStandardDateFormat.SHORT_STANDARD_DATE_FORMAT)
- returns: "98 May 28 14:22"
Supported API: true
Extendable: false
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFormat for the default locale is 'M/dd/yy h:mm a'.static final intFormat for the default locale is 'M/dd/yy'.static final intFormat for the default locale is 'h:mm a'.static final intFormat for the default locale is 'yyyy-MM-dd HH:mm:ss z'.static final intFormat for the default locale is 'yyyy-MM-dd'.static final intFormat for the default locale is 'yyyy-MM-dd HH:mm:ss'.static final intFormat for the default locale is 'dd MMM yy HH:mm'.static final intFormat for the default locale is 'MM/dd/yyyy'. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormats a Date into a date/time string.static StringFormats a Date into a date/time string.static StringFormats a Date into a date/time string.static StringFormats a Date into a date/time string.static StringFormats a Date into a date/time string.static StringFormats a Date into a date/time string.static StringFormats a Date into a date/time string.static intformatTypeFromString(String formatTypeString) Converts the name of the format type to the constant that it represents.static DateParses text from a string in the formatLONG_STANDARD_DATE_FORMATto produce a Date.static DateParses text from a string to produce a Date.static DateParses text from a string to produce a Date.static DateParses text from a string to produce a Date.static DateParses text from a string to produce a Date.static DateParses text from a string in the formatLONG_STANDARD_DATE_FORMATto produce a Date.
-
Field Details
-
LONG_STANDARD_DATE_FORMAT
public static final int LONG_STANDARD_DATE_FORMATFormat for the default locale is 'yyyy-MM-dd HH:mm:ss z'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
SHORT_STANDARD_DATE_FORMAT
public static final int SHORT_STANDARD_DATE_FORMATFormat for the default locale is 'dd MMM yy HH:mm'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
EXPLORER_STANDARD_DATE_FORMAT
public static final int EXPLORER_STANDARD_DATE_FORMATFormat for the default locale is 'M/dd/yy h:mm a'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
EXPLORER_STANDARD_DATE_ONLY_FORMAT
public static final int EXPLORER_STANDARD_DATE_ONLY_FORMATFormat for the default locale is 'M/dd/yy'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
EXPLORER_STANDARD_TIME_ONLY_FORMAT
public static final int EXPLORER_STANDARD_TIME_ONLY_FORMATFormat for the default locale is 'h:mm a'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
WF_STANDARD_DATE_ONLY_FORMAT
public static final int WF_STANDARD_DATE_ONLY_FORMATFormat for the default locale is 'MM/dd/yyyy'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONE
public static final int LONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONEFormat for the default locale is 'yyyy-MM-dd HH:mm:ss'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
LONG_STANDARD_DATE_FORMAT_MINUS_TIME
public static final int LONG_STANDARD_DATE_FORMAT_MINUS_TIMEFormat for the default locale is 'yyyy-MM-dd'. This may vary with other locales.
Supported API: true
Extendable: false- See Also:
-
-
Constructor Details
-
WTStandardDateFormat
public WTStandardDateFormat()No-arg constructor.
Supported API: true
-
-
Method Details
-
formatTypeFromString
Converts the name of the format type to the constant that it represents.- Parameters:
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"
- Returns:
- The format type:
LONG_STANDARD_DATE_FORMATSHORT_STANDARD_DATE_FORMATWF_STANDARD_DATE_ONLY_FORMATEXPLORER_STANDARD_DATE_FORMATEXPLORER_STANDARD_DATE_ONLY_FORMATEXPLORER_STANDARD_TIME_ONLY_FORMATLONG_STANDARD_DATE_FORMAT_MINUS_TIMEZONELONG_STANDARD_DATE_FORMAT_MINUS_TIME
Supported API: true
Extendable: false
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.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
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.formatType- The format. Valid values are: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
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.formatString- The format string (see java.text.SimpleDateFormat).- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.formatType- The format. Valid values are:locale- The locale whose date format symbols should be used.- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.formatType- The format. Valid values are:- Returns:
- The formatted date-time string.
Supported API: true
Extendable: false
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.locale- The locale whose date format symbols should be used.- Returns:
- The formatted date-time string in
LONG_STANDARD_DATE_FORMATformat.
Supported API: true
Extendable: false
-
format
Formats a Date into a date/time string.- Parameters:
date- The date to be formatted into aString.- Returns:
- The formatted date-time string in
LONG_STANDARD_DATE_FORMATformat.
Supported API: true
Extendable: false
-
parse
public static Date parse(String date, String formatString, Locale locale, TimeZone timeZone) throws ParseException Parses text from a string to produce a Date.- Parameters:
date- The string to parse.formatString- The format string (see java.text.SimpleDateFormat).locale- The locale.timeZone- The time zone to use in parsing.- Returns:
- A Date parsed from the string. In case of error, returns null.
- Throws:
ParseException-
Supported API: true
Extendable: false
-
parse
public static Date parse(String date, int formatType, Locale locale, TimeZone timeZone) throws ParseException Parses text from a string to produce a Date.- Parameters:
date- The string to parse.formatType- The format. Valid values are:locale- The locale.timeZone- The time zone to use in parsing.- Returns:
- A Date parsed from the string. In case of error, returns null.
- Throws:
ParseException-
Supported API: true
Extendable: false
-
parse
Parses text from a string to produce a Date.- Parameters:
date- The string to parse.formatString- The format string (see java.text.SimpleDateFormat).- Returns:
- A Date parsed from the string. In case of error, returns null.
- Throws:
ParseException-
Supported API: true
Extendable: false
-
parse
Parses text from a string to produce a Date.- Parameters:
date- The string to parse.formatType- The format. Valid values are:- Returns:
- A Date parsed from the string. In case of error, returns null.
- Throws:
ParseException-
Supported API: true
Extendable: false
-
parse
Parses text from a string in the formatLONG_STANDARD_DATE_FORMATto produce a Date.- Parameters:
date- The string to parse.locale- The locale.- Returns:
- A Date parsed from the string. In case of error, returns null.
- Throws:
ParseException-
Supported API: true
Extendable: false
-
parse
Parses text from a string in the formatLONG_STANDARD_DATE_FORMATto produce a Date.- Parameters:
date- The string to parse.- Returns:
- A Date parsed from the string. In case of error, returns null.
- Throws:
ParseException-
Supported API: true
Extendable: false
-