|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectariba.util.formatter.Formatter
ariba.util.formatter.DateFormatter
public class DateFormatter
DateFormatter is a subclass of Formatter which
is responsible for formatting, parsing, and comparing Date
objects.
| Field Summary | |
|---|---|
static String |
CannotParseDateKey
|
static String |
ClassName
Our Java class name. |
static String |
ConciseDateFormatKey
Format key for unpadded concise date format strings. |
static String |
ConciseDateTimeFormatKey
Format key for unpadded concise date/time format strings. |
static String |
DateMonthYearFormatKey
Format key for medium length date format strings (for printing). |
static String |
DayDateMonthYearFormatKey
Format key for medium length date format strings (for printing). |
static String |
DefaultFormatKey
localized resource string tag for the default date format pattern. |
static String |
FullDateMonthYearFormatKey
Format key for date format strings (for printing). |
static String |
FullDateMonthYearTZFormatKey
Format key for date format strings with time zone(for printing). |
static String |
FullDayDateMonthYearFormatKey
Format key for full date format strings. |
static String |
FullDayDateMonthYearTZFormatKey
Format key for full date format strings with time zone. |
static String |
LongDayDateMonthYearFormatKey
Format key for long date format strings. |
static String |
PaddedConciseDateFormatKey
Format key for padded concise date format strings. |
static String |
PaddedConciseDateTimeFormatKey
Format key for padded concise date/time format strings. |
static String |
PaddedDateTimeFormatKey
Format key for padded concise date/time format strings. |
| Fields inherited from interface ariba.util.core.Compare |
|---|
EqualTo, GreaterThan, LessThan |
| Constructor Summary | |
|---|---|
DateFormatter()
Creates a new DateFormatter. |
|
| Method Summary | |
|---|---|
static int |
compareDates(Date d1,
Date d2)
Compares two Date objects for sorting purposes. |
static String |
formatMillisAsDuration(long millis)
Formats the given millis as "D days, H hours, M
minutes". |
static String |
getDatePatternEquivalentToSunFormat(int style,
Locale locale)
Translates the Sun's constant defined in DateFormat into a localized
resource that is a valid Date format matching Sun's associated format. |
String |
getDateString(Date date,
Locale locale,
TimeZone timeZone)
|
String |
getDateString(Date date,
String pattern,
Locale locale,
TimeZone timeZone)
|
static String |
getDateTimePatternEquivalentToSunFormat(int style,
Locale locale)
Translates the Sun's constant defined in DateFormat into a localized
resource that is a valid Date format matching Sun's associated format. |
static Date |
getDateValue(Object object)
Returns a new Date derived from the given object in the
default locale. |
static Date |
getDateValue(Object object,
boolean calendarDate)
Returns a new Date derived from the given object in the
default locale. |
static Date |
getDateValue(Object object,
Locale locale)
Returns a new Date derived from the given object in the
given locale. |
static Date |
getDateValue(Object object,
Locale locale,
boolean calendarDate)
Returns a new Date derived from the given object in the
given locale. |
static Locale |
getDefaultLocale()
Returns the default locale to use for formatting, parsing, etc. |
static TimeZone |
getDefaultTimeZone()
|
static String |
getStringValue(Date date)
Returns a formatted string for the given Date in the
default locale and time zone. |
static String |
getStringValue(Date date,
Locale locale)
Returns a formatted string for the given Date in the
given locale using the default time zone. |
static String |
getStringValue(Date date,
Locale locale,
TimeZone timeZone)
Returns a formatted string for the given Date in the
given locale and time zone. |
static String |
getStringValue(Date date,
String pattern)
Returns a formatted string for the given Date in the
default locale and time zone. |
static String |
getStringValue(Date date,
String pattern,
Locale locale)
Returns a formatted string for the given Date in the
given locale using the default time zone. |
static String |
getStringValue(Date date,
String pattern,
Locale locale,
TimeZone timeZone)
Returns a formatted string for the given Date in the
given locale. |
static String |
getStringValue(Date date,
String pattern,
String tzString)
Returns a formatted string for the given Date in the
default locale. |
static String |
getStringValue(Date date,
String pattern,
TimeZone timeZone)
Returns a formatted string for the given Date in the
default locale. |
static String |
getStringValue(Date date,
TimeZone timeZone)
Returns a formatted string for the given Date in the
default locale using the given timeZone. |
static String |
getStringValueUsingFormats(Date date,
String formatsKey,
Locale locale,
TimeZone timeZone)
Returns a formatted string for the given Date in the
given locale. |
static String |
getTimePatternEquivalentToSunFormat(int style,
Locale locale)
Translates the Sun's constant defined in DateFormat into a localized
resource that is a valid Date format matching Sun's associated format. |
Object |
getValue(Object object,
Locale locale)
Returns a new Date derived from the given object in the
given locale. |
static Date |
parseDate(String string)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(String string,
boolean calendarDate)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(String string,
Locale locale)
Tries to parse the given string as a Date in the given
locale. |
static Date |
parseDate(String string,
Locale locale,
boolean calendarDate)
Tries to parse the given string as a Date in the given
locale using the default time zone. |
static Date |
parseDate(String string,
Locale locale,
TimeZone timeZone,
boolean calendarDate)
Tries to parse the given string as a Date in the given
locale and time zone using a list of default formats. |
static Date |
parseDate(String string,
String pattern)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(String string,
String pattern,
boolean calendarDate)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(String string,
String pattern,
Locale locale)
Tries to parse the given string as a Date in the given
locale using the default time zone. |
static Date |
parseDate(String string,
String pattern,
Locale locale,
boolean calendarDate)
Tries to parse the given string as a Date in the given
locale using the default time zone. |
static Date |
parseDate(String string,
String pattern,
Locale locale,
TimeZone timeZone,
boolean calendarDate)
Tries to parse the given string as a Date in the given
locale and time zone. |
static Date |
parseDateCXML(String string)
Tries to parse the given cXML date string (e.g. |
static Date |
parseDateGMT(String string)
Tries to parse the given GMT date string (e.g. |
static Date |
parseDateUsingFormats(String string,
Locale locale,
String formatsKey)
Tries to parse the given string as a date in the given locale using the default time zone. |
static Date |
parseDateUsingFormats(String string,
Locale locale,
String formatsKey,
boolean calendarDate)
Tries to parse the given string as a date in the given locale using the default time zone. |
static Date |
parseDateUsingFormats(String string,
Locale locale,
String formatsKey,
TimeZone timeZone,
boolean calendarDate)
Tries to parse the given string as a date in the given locale and time zone. |
static Date |
parseDateUTC(String dateStr)
Tries to parse the given UTC date string (e.g. |
Object |
parseString(String string,
Locale locale)
Tries to parse the given string into a Date object in the
given locale. |
Object |
parseString(String string,
Locale locale,
TimeZone tz)
Parse the given string as a Date in the given
locale and time zone. |
Object |
parseString(String string,
Locale locale,
TimeZone tz,
boolean calendarDate)
Parse the given string as a Date in the given
locale and time zone. |
static String |
toConciseDateString(Date date)
Returns a string representation of the date portion of the given Date in a concise, unpadded format, e.g. |
static String |
toConciseDateString(Date date,
Locale locale)
Returns a string representation of the date portion of the given Date in a concise, unpadded format, e.g. |
static String |
toConciseDateString(Date date,
Locale locale,
TimeZone tz)
Returns a string representation of the date portion of the given Date in a concise, unpadded format, e.g. |
static String |
toConciseDateTimeString(Date date)
Returns a string representation of the date and time for the given Date in a concise, unpadded format, e.g. |
static String |
toConciseDateTimeString(Date date,
Locale locale)
Returns a string representation of the date and time for the given Date in a concise, unpadded format, e.g. |
static String |
toConciseDateTimeString(Date date,
Locale locale,
TimeZone timeZone)
Returns a string representation of the date and time for the given Date in a concise, unpadded format, e.g. |
static String |
tocXML(Date date)
Returns a string representing the given Date in a
standard cXML format, e.g. |
static String |
tocXML(Date date,
TimeZone timezone)
Returns a string representing the given Date in a
standard cXML format, e.g. |
static String |
toDateMonthYearString(Date date)
Returns a string representation of the date portion of the given Date which includes the full month, day of month and
year, e.g. |
static String |
toDateMonthYearString(Date date,
Locale locale)
Returns a string representation of the date portion of the given Date which includes the full month, day of month and
year, e.g. |
static String |
toDayDateMonthYearString(Date date)
Returns a string representation of the date portion of the given Date which includes an abbreviated day of week, day of
month, month, and year, e.g. |
static String |
toDayDateMonthYearString(Date date,
Locale locale)
Returns a string representation of the date portion of the given Date which includes an abbreviated day of week, day of
month, month, and year, e.g. |
static String |
toDayDateMonthYearString(Date date,
Locale locale,
TimeZone tz)
Returns a string representation of the date portion of the given Date which includes an abbreviated day of week, day of
month, month, and year, e.g. |
static String |
toDayOfWeekString(Date date)
Returns an abbreviated string representation of the day of the week represented by the given Date, e.g. |
static String |
toDayOfWeekString(Date date,
Locale locale)
Returns an abbreviated string representation of the day of the week represented by the given Date, e.g. |
static String |
toFileTimeString(Date date)
|
static String |
toFullDateMonthYearString(Date date)
Returns a string representation of the given Date which
includes the full month, day of month, year and time, e.g. |
static String |
toFullDateMonthYearString(Date date,
Locale locale)
Returns a string representation of the given Date which
includes the full month, day of month, year and time, e.g. |
static String |
toFullDateMonthYearTZString(Date date,
Locale locale,
TimeZone tz)
Returns a string representation of the given Date which
includes the full month, day of month, year, time and time zone, e.g. |
static String |
toFullDayDateMonthYearString(Date date)
Returns a string representation of the given Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. |
static String |
toFullDayDateMonthYearString(Date date,
Locale locale)
Returns a string representation of the given Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. |
static String |
toFullDayDateMonthYearString(Date date,
Locale locale,
TimeZone tz)
Returns a string representation of the given Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. |
static String |
toFullDayDateMonthYearTZString(Date date,
Locale locale,
TimeZone tz)
Returns a string representation of the given Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. |
static String |
toGMT(Date date)
Returns a string representing the given Date in a
standard GMT format, e.g. |
static String |
toHourMinSecString(Date date)
Returns a string representation of the time portion of the given Date which includes hours, minutes and seconds, e.g. |
static String |
toHourMinSecString(Date date,
Locale locale)
Returns a string representation of the time portion of the given Date which includes hours, minutes and seconds, e.g. |
static String |
toJavaFormat(Date date)
|
static String |
toJavaFormat(Date date,
Locale locale)
|
static String |
toLongDayDateMonthYearString(Date date)
Returns a string representation of the date portion of the given Date which includes the full day of week, month, day of
month and year, e.g. |
static String |
toLongDayDateMonthYearString(Date date,
Locale locale)
Returns a string representation of the date portion of the given Date which includes the full day of week, month, day of
month and year, e.g. |
static String |
toMilitaryTimeString(Date date)
Returns a string representation of the time portion of the given Date in military time format, e.g. |
static String |
toPaddedConciseDateString(Date date)
Returns a string representation of the date portion of the given Date in a concise, padded format, e.g. |
static String |
toPaddedConciseDateString(Date date,
Locale locale)
Returns a string representation of the date portion of the given Date in a concise, padded format, e.g. |
static String |
toPaddedConciseDateString(Date date,
Locale locale,
TimeZone tz)
Returns a string representation of the date portion of the given Date in a concise, padded format, e.g. |
static String |
toPaddedConciseDateTimeString(Date date)
Returns a string representation of the date and time for the given Date in a concise, padded format, e.g. |
static String |
toPaddedConciseDateTimeString(Date date,
Locale locale)
Returns a string representation of the date and time for the given Date in a concise, padded format, e.g. |
static String |
toPaddedConciseDateTimeString(Date date,
Locale locale,
TimeZone timeZone)
Returns a string representation of the date and time for the given Date in a concise, padded format, e.g. |
static String |
toPaddedDateTimeString(Date date)
Returns a string representation of the date and time for the given DateTime in a padded format, e.g. |
static String |
toPaddedDateTimeString(Date date,
Locale locale)
Returns a string representation of the date and time for the given DateTime in a padded format, e.g. |
static String |
toPaddedDateTimeString(Date date,
Locale locale,
TimeZone timeZone)
Returns a string representation of the date and time for the given DateTime in a padded format, e.g. |
static String |
toUTC(Date date)
Returns a string representing the given Date in the
Coordinated Universal Time (UTC) as specified in
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime,
e.g. |
static String |
toYearMonthDate(Date date)
Returns a string representation of the given Date in a
compact format with year, month, and day of month run together, e.g. |
| Methods inherited from class ariba.util.formatter.Formatter |
|---|
canFormatNulls, compare, compare, equal, equal, getFormat, getFormat, getFormatterClassForType, getFormatterForObject, getFormatterForType, getLocale, getStringValue, getStringValue, getValue, handlesNulls, isBidirectional, makeParseException, makeParseException, objectsAreEqual, objectsAreEqual, parse, parse, parseString, parseString, quickCompare, quickCompare, quickCompareValue, registerFormatter |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ClassName
public static final String DefaultFormatKey
public static final String ConciseDateFormatKey
public static final String PaddedConciseDateFormatKey
public static final String ConciseDateTimeFormatKey
public static final String PaddedConciseDateTimeFormatKey
public static final String PaddedDateTimeFormatKey
public static final String DayDateMonthYearFormatKey
public static final String DateMonthYearFormatKey
public static final String FullDateMonthYearFormatKey
public static final String FullDateMonthYearTZFormatKey
public static final String LongDayDateMonthYearFormatKey
public static final String FullDayDateMonthYearFormatKey
public static final String FullDayDateMonthYearTZFormatKey
public static final String CannotParseDateKey
| Constructor Detail |
|---|
public DateFormatter()
DateFormatter.
| Method Detail |
|---|
public static String getStringValue(Date date)
Date in the
default locale and time zone. Uses a default date format string,
e.g. "Wed, 2 Dec 98". The exact format is locale-specific.
date - the Date to format into a string
Date
public static String getStringValue(Date date,
Locale locale)
Date in the
given locale using the default time zone. Uses a default date format
string, e.g. "Wed, 2 Dec 98". The exact format is locale-specific.
The locale parameter must be non-null.
date - the Date to format into a stringlocale - the Locale to use for formatting
Date
public static String getStringValue(Date date,
TimeZone timeZone)
Date in the
default locale using the given timeZone. Uses a default
date format string, e.g. "Wed, 2 Dec 98". The exact format is
locale-specific. The timeZone parameter must be
non-null.
date - the Date to format into a stringtimeZone - the TimeZone to use for formatting
Date
public static String getStringValue(Date date,
Locale locale,
TimeZone timeZone)
Date in the
given locale and time zone. Uses a default date format string,
e.g. "Wed, 2 Dec 98". The exact format is locale-specific. The
locale and timeZone parameters must be
non-null.
date - the Date to format into a stringlocale - the Locale to use for formattingtimeZone - the TimeZone to use for formatting
Date
public static String getStringValue(Date date,
String pattern)
Date in the
default locale and time zone. Uses the date format pattern
pattern as the template for how the date should be
formatted.
date - the Date to format into a stringpattern - the locale-specific date format pattern to use for formatting
Date
public static String getStringValue(Date date,
String pattern,
Locale locale)
Date in the
given locale using the default time zone. Uses the date format
pattern pattern as the template for how the date should
be formatted.
date - the Date to format into a stringpattern - the locale-specific date format pattern to use for formattinglocale - the Locale to use for formatting
Date
public static String getStringValue(Date date,
String pattern,
String tzString)
Date in the
default locale. Uses the date format pattern pattern as
the template for how the date should be formatted. Looks up a
TimeZone based on the given timeZone string
(e.g. "GMT", "PST", etc.) and uses it to format the date in the given
time zone.
date - the Date to format into a stringpattern - the locale-specific date format pattern to use for formattingtzString - the identifier of the time zone to use for formatting
Date
public static String getStringValue(Date date,
String pattern,
TimeZone timeZone)
Date in the
default locale. Uses the date format pattern pattern as
the template for how the date should be formatted. Uses the given
timeZone to format the date.
date - the Date to format into a stringpattern - the date format pattern to use for formattingtimeZone - the TimeZone to use for formatting
Date
public static String getStringValue(Date date,
String pattern,
Locale locale,
TimeZone timeZone)
Date in the
given locale. Uses the date format pattern pattern as
the template for how the date should be formatted. Looks up a
TimeZone based on the given timeZone string
(e.g. "GMT", "PST", etc.) and uses it to format the date in the given
time zone. The locale parameter must be non-null.
date - the Date to format into a stringpattern - the date format pattern to use for formattinglocale - the Locale to use for formattingtimeZone - the TimeZone to use for formatting
Date
public String getDateString(Date date,
Locale locale,
TimeZone timeZone)
public String getDateString(Date date,
String pattern,
Locale locale,
TimeZone timeZone)
public static String getStringValueUsingFormats(Date date,
String formatsKey,
Locale locale,
TimeZone timeZone)
Date in the
given locale. Uses the formats key formatsKey to look up
the template for how the date should be formatted. Looks up a
TimeZone based on the given timeZone string
(e.g. "GMT", "PST", etc.) and uses it to format the date in the given
time zone.
date - the Date to format into a stringformatsKey - key to the date format pattern, must not be null.locale - the Locale to use for formatting, must not be null.timeZone - the TimeZone to use for formatting, must not be null.
Datepublic static String formatMillisAsDuration(long millis)
millis as "D days, H hours, M
minutes". If millis is less than the number of
milliseconds in a minute, then the format is "S seconds". If it's
less than the number of millis in a second, then we use "M
milliseconds".
public static String toConciseDateString(Date date)
Date in a concise, unpadded format, e.g. "1/12/1999".
The exact format is locale-specific.
date - the Date to format
Date
public static String toConciseDateString(Date date,
Locale locale)
Date in a concise, unpadded format, e.g. "1/12/1999".
The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toConciseDateString(Date date,
Locale locale,
TimeZone tz)
Date in a concise, unpadded format, e.g. "1/12/1999".
The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtz - the TimeZone, to use for formatting
Datepublic static String toPaddedConciseDateString(Date date)
Date in a concise, padded format, e.g. "01/12/1999". The
exact format is locale-specific.
date - the Date to format
Date
public static String toPaddedConciseDateString(Date date,
Locale locale)
Date in a concise, padded format, e.g. "01/12/1999". The
exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toPaddedConciseDateString(Date date,
Locale locale,
TimeZone tz)
Date in a concise, padded format, e.g. "01/12/1999". The
exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtz - the TimeZone, to use for formatting
Datepublic static String toConciseDateTimeString(Date date)
Date in a concise, unpadded format, e.g. "1/12/1999 3:14
PM". The exact format is locale-specific.
date - the Date to format
Date
public static String toConciseDateTimeString(Date date,
Locale locale)
Date in a concise, unpadded format, e.g. "1/12/1999 3:14
PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toConciseDateTimeString(Date date,
Locale locale,
TimeZone timeZone)
Date in a concise, unpadded format, e.g. "1/12/1999 3:14
PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtimeZone - the TimeZone, to use for formatting
Datepublic static String toPaddedConciseDateTimeString(Date date)
Date in a concise, padded format, e.g. "01/12/1999 03:14
PM". The exact format is locale-specific.
date - the Date to format
Date
public static String toPaddedConciseDateTimeString(Date date,
Locale locale)
Date in a concise, padded format, e.g. "01/12/1999 03:14
PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toPaddedConciseDateTimeString(Date date,
Locale locale,
TimeZone timeZone)
Date in a concise, padded format, e.g. "01/12/1999 03:14
PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtimeZone - the TimeZone, to use for formatting
Datepublic static String toPaddedDateTimeString(Date date)
DateTime in a padded format, e.g. "01/12/1999 03:14:34
PM". The exact format is locale-specific.
date - the Date to format
Date
public static String toPaddedDateTimeString(Date date,
Locale locale)
DateTime in a padded format, e.g. "01/12/1999 03:14:34
PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toPaddedDateTimeString(Date date,
Locale locale,
TimeZone timeZone)
DateTime in a padded format, e.g. "01/12/1999 03:14:34
PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtimeZone - the TimeZone, to use for formatting
Datepublic static String toDayDateMonthYearString(Date date)
Date which includes an abbreviated day of week, day of
month, month, and year, e.g. "Mon, 02 Jun, 1999". The exact format is
locale-specific.
date - the Date to format
Date
public static String toDayDateMonthYearString(Date date,
Locale locale)
Date which includes an abbreviated day of week, day of
month, month, and year, e.g. "Mon, 02 Jun, 1999". The exact format is
locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toDayDateMonthYearString(Date date,
Locale locale,
TimeZone tz)
Date which includes an abbreviated day of week, day of
month, month, and year, e.g. "Mon, 02 Jun, 1999". The exact format is
locale-specific.
date - date the Date to formatlocale - locale the Locale to use for formattingtz - Time zone.
Datepublic static String toLongDayDateMonthYearString(Date date)
Date which includes the full day of week, month, day of
month and year, e.g. "Monday, January 31, 1999". The exact format is
locale-specific.
date - the Date to format
Date
public static String toLongDayDateMonthYearString(Date date,
Locale locale)
Date which includes the full day of week, month, day of
month and year, e.g. "Monday, January 31, 1999". The exact format is
locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Datepublic static String toFullDayDateMonthYearString(Date date)
Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. "Monday, January 31, 1999 at 3:15 PM". The
exact format is locale-specific.
date - the Date to format
Date
public static String toFullDayDateMonthYearString(Date date,
Locale locale)
Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. "Monday, January 31, 1999 at 3:15 PM". The
exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toFullDayDateMonthYearString(Date date,
Locale locale,
TimeZone tz)
Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. "Monday, January 31, 1999 at 3:15 PM". The
exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtz - the TimeZone to use for formatting
Date
public static String toFullDayDateMonthYearTZString(Date date,
Locale locale,
TimeZone tz)
Date
(including time) which includes the full day of week, month, day of
month, year and time e.g. "Monday, January 31, 1999 at 3:15 PM,
Pacific Daylight Time". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtz - the TimeZone to use for formatting
Datepublic static String toDateMonthYearString(Date date)
Date which includes the full month, day of month and
year, e.g. "January 31, 1999". The exact format is locale-specific.
date - the Date to format
Date
public static String toDateMonthYearString(Date date,
Locale locale)
Date which includes the full month, day of month and
year, e.g. "January 31, 1999". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Datepublic static String toFullDateMonthYearString(Date date)
Date which
includes the full month, day of month, year and time, e.g. "January
31, 1999 at 3:15 PM". The exact format is locale-specific.
date - the Date to format
Date
public static String toFullDateMonthYearString(Date date,
Locale locale)
Date which
includes the full month, day of month, year and time, e.g. "January
31, 1999 at 3:15 PM". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Date
public static String toFullDateMonthYearTZString(Date date,
Locale locale,
TimeZone tz)
Date which
includes the full month, day of month, year, time and time zone, e.g. "January
31, 1999 at 3:15 PM Pacific Daylight Time". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formattingtz - the TimeZone to use for formatting
Datepublic static String toHourMinSecString(Date date)
Date which includes hours, minutes and seconds, e.g.
"3:01:42". The exact format is locale-specific.
date - the Date to format
Date
public static String toHourMinSecString(Date date,
Locale locale)
Date which includes hours, minutes and seconds, e.g.
"3:01:42". The exact format is locale-specific.
date - the Date to formatlocale - the Locale to use for formatting
Datepublic static String toDayOfWeekString(Date date)
Date, e.g. "Mon", "Tue", etc.
date - the Date to format
Date
public static String toDayOfWeekString(Date date,
Locale locale)
Date, e.g. "Mon", "Tue", etc.
date - the Date to formatlocale - the Locale to use for formatting
Datepublic static String toGMT(Date date)
Date in a
standard GMT format, e.g. "12 Aug 1995 02:30:00 GMT". This method
should be used in place of the deprecated toGMTString.
This format is not locale-specific.
date - the Date to format
Datepublic static String toYearMonthDate(Date date)
Date in a
compact format with year, month, and day of month run together, e.g.
"19990521". This format is not locale-specific.
date - the Date to format
Datepublic static String toMilitaryTimeString(Date date)
Date in military time format, e.g. "21:05:35". This
format is not locale-specific.
date - the Date to format
Datepublic static String toFileTimeString(Date date)
public static String toJavaFormat(Date date)
public static String toJavaFormat(Date date,
Locale locale)
public static String toUTC(Date date)
Date in the
Coordinated Universal Time (UTC) as specified in
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime,
e.g. "2003-08-30T03:01:39Z". This format is not locale-specific.
date - the Date to format
Datepublic static String tocXML(Date date)
Date in a
standard cXML format, e.g. "1999-03-12T18:39:09-08:00". The last
six digits represent difference between local time and GMT time.
This format is not locale-specific.
date - the Date to format
Date
public static String tocXML(Date date,
TimeZone timezone)
Date in a
standard cXML format, e.g. "1999-03-12T18:39:09-08:00". The last
six digits represent difference between local time and GMT time.
This format is not locale-specific.
date - the Date to formattimezone - the TimeZone to used. If null,
DateFormatter.getDefaultTimeZone() will be used.
Date
public static String getTimePatternEquivalentToSunFormat(int style,
Locale locale)
DateFormat into a localized
resource that is a valid Date format matching Sun's associated format.
Sun has defined 4 constants (SHORT, MEDIUM, LONG and FULL) and has associated
to them a time and a date format. This method will return the date format that
is the closest to Sun's format. In many cases the format will be identical.
Warning: For now, only SHORT and MEDIUM are implemented. You will get
an assert for the others.
style - date format as defined by Sunlocale - locale to use to look up the date format
public static String getDatePatternEquivalentToSunFormat(int style,
Locale locale)
DateFormat into a localized
resource that is a valid Date format matching Sun's associated format.
Sun has defined 4 constants (SHORT, MEDIUM, LONG and FULL) and has associated
to them a time and a date format. This method will return the date format that
is the closest to Sun's format. In many cases the format will be identical.
Warning: For now, only SHORT and LONG are implemented. You will get
an assert for the others.
style - date format as defined by Sunlocale - locale to use to look up the date format
public static String getDateTimePatternEquivalentToSunFormat(int style,
Locale locale)
DateFormat into a localized
resource that is a valid Date format matching Sun's associated format.
Sun has defined 4 constants (SHORT, MEDIUM, LONG and FULL) and has associated
to them a time and a date format. This method will return the date format that
is the closest to Sun's format. In many cases the format will be identical.
Warning: For now, only SHORT is implemented. You will get
an assert for the others.
style - date format as defined by Sunlocale - locale to use to look up the date format
public static Date parseDate(String string)
throws ParseException
Date in the default
locale and time zone. This method parses the string using a list of
default formats specified by the SystemFormats and DefaultFmt entries in
the resource.date.csv file. The actual format to use is the first format in
the list where the string can be successfully parsed. It is important to realize
that the actual format used may not be what the caller intends to use. Consequently,
the parsed Date object may not be the value as expected by the caller. If the caller
intends to use a specific format, it is recommended that parseDate(java.lang.String, java.lang.String)
or parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String) be used instead.
string - the string to parse as a Date
Date derived from the string
ParseException - if the string can't be parsed as a
DateparseDate(java.lang.String, java.lang.String),
parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String)
public static Date parseDate(String string,
boolean calendarDate)
throws ParseException
Date in the default
locale and time zone. This method parses the string using a list of
default formats specified by the SystemFormats and DefaultFmt entries in
the resource.date.csv file. The actual format to use is the first format in
the list where the string can be successfully parsed. It is important to realize
that the actual format used may not be what the caller intends to use. Consequently,
the parsed Date object may not be the value as expected by the caller. If the caller
intends to use a specific format, it is recommended that parseDate(String, String, boolean) or
parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String, boolean) be used instead.
string - the string to parse as a DatecalendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
DateparseDate(String, String, boolean),
parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String, boolean)
public static Date parseDate(String string,
Locale locale)
throws ParseException
Date in the given
locale. This method parses the string using a list of
default formats specified by the SystemFormats and DefaultFmt entries in
the resource.date.csv file. The actual format to use is the first format in
the list where the string can be successfully parsed. It is important to realize
that the actual format used may not be what the caller intends to use. Consequently,
the parsed Date object may not be the value as expected by the caller. If the caller
intends to use a specific format, it is recommended that
parseDate(String, String, java.util.Locale) or
parseDateUsingFormats(String,java.util.Locale,String)
be used instead.
string - the string to parse as a Datelocale - the Locale to use for parsing, must not be null
Date derived from the string
ParseException - if the string can't be parsed as a
DateparseDate(String,String,java.util.Locale),
parseDateUsingFormats(String,java.util.Locale,String)
public static Date parseDate(String string,
Locale locale,
boolean calendarDate)
throws ParseException
Date in the given
locale using the default time zone. This method parses the string using a list of
default formats specified by the SystemFormats and DefaultFmt entries in
the resource.date.csv file. The actual format to use is the first format in
the list where the string can be successfully parsed. It is important to realize
that the actual format used may not be what the caller intends to use. Consequently,
the parsed Date object may not be the value as expected by the caller. If the caller
intends to use a specific format, it is recommended that
parseDate(String, String, java.util.Locale, boolean) or
parseDateUsingFormats(String,java.util.Locale,String,boolean)
be used instead.
string - the string to parse as a Datelocale - the Locale to use for parsing, must not be nullcalendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
DateparseDate(String, String, java.util.Locale, boolean),
parseDateUsingFormats(String,java.util.Locale,String,boolean)
public static Date parseDate(String string,
Locale locale,
TimeZone timeZone,
boolean calendarDate)
throws ParseException
Date in the given
locale and time zone using a list of default formats. This list is
specified by the SystemFormats and DefaultFmt entries in
the resource.date.csv file. The actual format to use is the first format in
the list where the string can be successfully parsed. It is important to realize
that the actual format used may not be what the caller intends to use. Consequently,
the parsed Date object may not be the value as expected by the caller. If the caller
intends to use a specific format, it is recommended that
parseDate(String,String,java.util.Locale,java.util.TimeZone,boolean) or
parseDateUsingFormats(String,java.util.Locale,String,java.util.TimeZone,boolean)
be used instead.
string - the string to parse as a Datelocale - the Locale to use for parsing, must not be null.timeZone - the TimeZone to use for parsing, must not be null.calendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
DateparseDate(String,String,java.util.Locale,java.util.TimeZone,boolean),
boolean calendarDate)
public static Date parseDateUsingFormats(String string,
Locale locale,
String formatsKey)
formatsKey to look
up a string which is the list of date formats to use to try and parse
the string as a date.
string - the string to parse as a Datelocale - the Locale to use for parsing, must be non-null.formatsKey - the date format to use for parsing
Date derived from the string, null if the sting cannot be parsed.
public static Date parseDateUsingFormats(String string,
Locale locale,
String formatsKey,
boolean calendarDate)
formatsKey to look
up a string which is the list of date formats to use to try and parse
the string as a date.
string - the string to parse as a Datelocale - the Locale to use for parsing, must be non-null.formatsKey - the date format to use for parsingcalendarDate - if true, a calendar date will be created
Date derived from the string, null if the sting cannot be parsed.
public static Date parseDateUsingFormats(String string,
Locale locale,
String formatsKey,
TimeZone timeZone,
boolean calendarDate)
formatsKey to look up a string
which is the list of date formats to use to try and parse the string
as a date.
string - the string to parse as a Datelocale - the Locale to use for parsing, must be non-null.formatsKey - the date format to use for parsingtimeZone - the TimeZone to use for parsing, must be non-null.calendarDate - if true, a calendar date will be created
Date derived from the string, null if the sting cannot be parsed.
public static Date parseDate(String string,
String pattern)
throws ParseException
Date in the default
locale and time zone. Uses the date format pattern
pattern as the template for how the date should be
parsed.
string - the string to parse as a Datepattern - the date format pattern to use for parsing in the
default lcoale
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the given format pattern
public static Date parseDate(String string,
String pattern,
boolean calendarDate)
throws ParseException
Date in the default
locale and time zone. Uses the date format pattern
pattern as the template for how the date should be
parsed.
string - the string to parse as a Datepattern - the date format pattern to use for parsing in the
default localecalendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the given format pattern
public static Date parseDate(String string,
String pattern,
Locale locale)
throws ParseException
Date in the given
locale using the default time zone. Uses the date format pattern
pattern as the template for how the date should be
parsed. The locale parameter must be non-null.
string - the string to parse as a Datepattern - the date format pattern to use for parsing for the specified localelocale - the Locale to use for parsing
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the given format pattern
public static Date parseDate(String string,
String pattern,
Locale locale,
boolean calendarDate)
throws ParseException
Date in the given
locale using the default time zone. Uses the date format pattern
pattern as the template for how the date should be
parsed. The locale parameter must be non-null.
string - the string to parse as a Datepattern - the date format pattern to use for parsing for the specified localelocale - the Locale to use for parsingcalendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the given format pattern
public static Date parseDate(String string,
String pattern,
Locale locale,
TimeZone timeZone,
boolean calendarDate)
throws ParseException
Date in the given
locale and time zone. Uses the date format pattern
pattern as the template for how the date should be
parsed. The locale and timeZone parameters
must be non-null.
string - the string to parse as a Datepattern - the date format pattern to use for parsing for the specified localelocale - the Locale to use for parsingtimeZone - the TimeZone to use for parsingcalendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the given format pattern
public static Date parseDateGMT(String string)
throws ParseException
Date in the default locale and time zone.
Uses the GMT date format pattern as the parsing template.
string - the string to parse as a Date
Date derived from the string
ParseException - if the string can't be parsed as a
Date using a GMT format patternpublic static TimeZone getDefaultTimeZone()
public static Locale getDefaultLocale()
public static Date parseDateUTC(String dateStr)
throws ParseException
Date.
Uses the UTC date pattern as the parsing template.
dateStr - the string to parse as a Date
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the UTC format pattern
public static Date parseDateCXML(String string)
throws ParseException
Date. Uses the cXML date pattern as the parsing template.
string - the string to parse as a Date
Date derived from the string
ParseException - if the string can't be parsed as a
Date using the cXML GMT format pattern
public static Date getDateValue(Object object,
boolean calendarDate)
Date derived from the given object in the
default locale. If the object is not a Date, it is
converted to a string and parsed. Returns null if the object can't be
converted to a Date.
object - the object to convert to a DatecalendarDate - if true, a calendar date will be created
Date derived from the given objectpublic static Date getDateValue(Object object)
Date derived from the given object in the
default locale. If the object is not a Date, it is
converted to a string and parsed. Returns null if the object can't be
converted to a Date.
object - the object to convert to a Date
Date derived from the given object
public static Date getDateValue(Object object,
Locale locale)
Date derived from the given object in the
given locale. If the object is not a Date, it is
converted to a string and parsed. Returns null if the object can't be
converted to a Date.
object - the object to convert to a Datelocale - the Locale to use for conversion
Date derived from the given object
public static Date getDateValue(Object object,
Locale locale,
boolean calendarDate)
Date derived from the given object in the
given locale. If the object is not a Date, it is
converted to a string and parsed. Returns null if the object can't be
converted to a Date.
object - the object to convert to a Datelocale - the Locale to use for conversioncalendarDate - if true, and the Date must be parsed from
the object, a calendar date will be created
Date derived from the given object
public static int compareDates(Date d1,
Date d2)
Date objects for sorting purposes. Returns
an int value which is less than, equal to, or greater
than zero depending on whether the first object sorts before, the
same, or after the second object.
d1 - the first Date to compared2 - the second Date to compare
int value which determines how the two
objects should be ordered
public Object parseString(String string,
Locale locale)
throws ParseException
Date object in the
given locale. The string is assumed to be non-null and trimmed of
leading and trailing whitespace.
string - the string to parselocale - the Locale to use for parsing
Date object derived from the string
ParseException - if the string can't be parsed as a
Date object in the given locale
public Object parseString(String string,
Locale locale,
TimeZone tz)
throws ParseException
Date in the given
locale and time zone.
string - the string to parse as a Datelocale - the Locale to use for parsingtz - the TimeZone to use for parsing
Date derived from the string
ParseException - if the string can't be parsed as a
Date
public Object parseString(String string,
Locale locale,
TimeZone tz,
boolean calendarDate)
throws ParseException
Date in the given
locale and time zone. The locale and
timeZone parameters must be non-null.
string - the string to parse as a Datelocale - the Locale to use for parsingtz - the TimeZone to use for parsingcalendarDate - if true, a calendar date will be created
Date derived from the string
ParseException - if the string can't be parsed as a
Date
public Object getValue(Object object,
Locale locale)
Date derived from the given object in the
given locale. If the object is not a Date, it is
converted to a string and parsed. Returns null if the object can't be
parsed as a Date.
getValue in class Formatterobject - the object to convert to a Datelocale - the Locale to use for conversion
Date derived from the given object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||