|
|||||||||
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 java.lang.String |
CannotParseDateKey
|
static java.lang.String |
ClassName
Our Java class name. |
static java.lang.String |
ConciseDateFormatKey
Format key for unpadded concise date format strings. |
static java.lang.String |
ConciseDateTimeFormatKey
Format key for unpadded concise date/time format strings. |
static java.lang.String |
DateMonthYearFormatKey
Format key for medium length date format strings (for printing). |
static java.lang.String |
DayDateMonthYearFormatKey
Format key for medium length date format strings (for printing). |
static java.lang.String |
DefaultFormatKey
localized resource string tag for the default date format pattern. |
static java.lang.String |
FullDateMonthYearFormatKey
Format key for date format strings (for printing). |
static java.lang.String |
FullDateMonthYearTZFormatKey
Format key for date format strings with time zone(for printing). |
static java.lang.String |
FullDayDateMonthYearFormatKey
Format key for full date format strings. |
static java.lang.String |
FullDayDateMonthYearTZFormatKey
Format key for full date format strings with time zone. |
static java.lang.String |
LongDayDateMonthYearFormatKey
Format key for long date format strings. |
static java.lang.String |
PaddedConciseDateFormatKey
Format key for padded concise date format strings. |
static java.lang.String |
PaddedConciseDateTimeFormatKey
Format key for padded concise date/time format strings. |
static java.lang.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(java.util.Date d1,
java.util.Date d2)
Compares two Date objects for sorting purposes. |
static java.lang.String |
formatMillisAsDuration(long millis)
Formats the given millis as "D days, H hours, M
minutes". |
static java.lang.String |
getDatePatternEquivalentToSunFormat(int style,
java.util.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. |
java.lang.String |
getDateString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone timeZone)
|
java.lang.String |
getDateString(java.util.Date date,
java.lang.String pattern,
java.util.Locale locale,
java.util.TimeZone timeZone)
|
static java.lang.String |
getDateTimePatternEquivalentToSunFormat(int style,
java.util.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(java.lang.Object object)
Returns a new Date derived from the given object in the
default locale. |
static Date |
getDateValue(java.lang.Object object,
boolean calendarDate)
Returns a new Date derived from the given object in the
default locale. |
static Date |
getDateValue(java.lang.Object object,
java.util.Locale locale)
Returns a new Date derived from the given object in the
given locale. |
static Date |
getDateValue(java.lang.Object object,
java.util.Locale locale,
boolean calendarDate)
Returns a new Date derived from the given object in the
given locale. |
static java.util.Locale |
getDefaultLocale()
Returns the default locale to use for formatting, parsing, etc. |
static java.util.TimeZone |
getDefaultTimeZone()
|
static int |
getMillisecondsTest(java.lang.String s)
|
static java.lang.String |
getStringValue(java.util.Date date)
Returns a formatted string for the given Date in the
default locale and time zone. |
static java.lang.String |
getStringValue(java.util.Date date,
java.util.Locale locale)
Returns a formatted string for the given Date in the
given locale using the default time zone. |
static java.lang.String |
getStringValue(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a formatted string for the given Date in the
given locale and time zone. |
static java.lang.String |
getStringValue(java.util.Date date,
java.lang.String pattern)
Returns a formatted string for the given Date in the
default locale and time zone. |
static java.lang.String |
getStringValue(java.util.Date date,
java.lang.String pattern,
java.util.Locale locale)
Returns a formatted string for the given Date in the
given locale using the default time zone. |
static java.lang.String |
getStringValue(java.util.Date date,
java.lang.String pattern,
java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a formatted string for the given Date in the
given locale. |
static java.lang.String |
getStringValue(java.util.Date date,
java.lang.String pattern,
java.lang.String tzString)
Returns a formatted string for the given Date in the
default locale. |
static java.lang.String |
getStringValue(java.util.Date date,
java.lang.String pattern,
java.util.TimeZone timeZone)
Returns a formatted string for the given Date in the
default locale. |
static java.lang.String |
getStringValue(java.util.Date date,
java.util.TimeZone timeZone)
Returns a formatted string for the given Date in the
default locale using the given timeZone . |
static java.lang.String |
getStringValueUsingFormats(java.util.Date date,
java.lang.String formatsKey,
java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a formatted string for the given Date in the
given locale. |
static java.lang.String |
getTimePatternEquivalentToSunFormat(int style,
java.util.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. |
java.lang.Object |
getValue(java.lang.Object object,
java.util.Locale locale)
Returns a new Date derived from the given object in the
given locale. |
static Date |
parseDate(java.lang.String string)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(java.lang.String string,
boolean calendarDate)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(java.lang.String string,
java.util.Locale locale)
Tries to parse the given string as a Date in the given
locale. |
static Date |
parseDate(java.lang.String string,
java.util.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(java.lang.String string,
java.util.Locale locale,
java.util.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(java.lang.String string,
java.lang.String pattern)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(java.lang.String string,
java.lang.String pattern,
boolean calendarDate)
Tries to parse the given string as a Date in the default
locale and time zone. |
static Date |
parseDate(java.lang.String string,
java.lang.String pattern,
java.util.Locale locale)
Tries to parse the given string as a Date in the given
locale using the default time zone. |
static Date |
parseDate(java.lang.String string,
java.lang.String pattern,
java.util.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(java.lang.String string,
java.lang.String pattern,
java.util.Locale locale,
java.util.TimeZone timeZone,
boolean calendarDate)
Tries to parse the given string as a Date in the given
locale and time zone. |
static Date |
parseDateCXML(java.lang.String string)
Tries to parse the given cXML date string (e.g. |
static Date |
parseDateCXMLWithMs(java.lang.String string,
boolean addMillisecondValue)
Tries to parse the given cXML date string (e.g. |
static Date |
parseDateGMT(java.lang.String string)
Tries to parse the given GMT date string (e.g. |
static Date |
parseDateUsingFormats(java.lang.String string,
java.util.Locale locale,
java.lang.String formatsKey)
Tries to parse the given string as a date in the given locale using the default time zone. |
static Date |
parseDateUsingFormats(java.lang.String string,
java.util.Locale locale,
java.lang.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(java.lang.String string,
java.util.Locale locale,
java.lang.String formatsKey,
java.util.TimeZone timeZone,
boolean calendarDate)
Tries to parse the given string as a date in the given locale and time zone. |
static Date |
parseDateUTC(java.lang.String dateStr)
Tries to parse the given UTC date string (e.g. |
java.lang.Object |
parseString(java.lang.String string,
java.util.Locale locale)
Tries to parse the given string into a Date object in the
given locale. |
java.lang.Object |
parseString(java.lang.String string,
java.util.Locale locale,
java.util.TimeZone tz)
Parse the given string as a Date in the given
locale and time zone. |
java.lang.Object |
parseString(java.lang.String string,
java.util.Locale locale,
java.util.TimeZone tz,
boolean calendarDate)
Parse the given string as a Date in the given
locale and time zone. |
static java.lang.String |
toConciseDateString(java.util.Date date)
Returns a string representation of the date portion of the given Date in a concise, unpadded format, e.g. |
static java.lang.String |
toConciseDateString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the date portion of the given Date in a concise, unpadded format, e.g. |
static java.lang.String |
toConciseDateString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a string representation of the date portion of the given Date in a concise, unpadded format, e.g. |
static java.lang.String |
toConciseDateTimeString(java.util.Date date)
Returns a string representation of the date and time for the given Date in a concise, unpadded format, e.g. |
static java.lang.String |
toConciseDateTimeString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the date and time for the given Date in a concise, unpadded format, e.g. |
static java.lang.String |
toConciseDateTimeString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a string representation of the date and time for the given Date in a concise, unpadded format, e.g. |
static java.lang.String |
tocXML(java.util.Date date)
Returns a string representing the given Date in a
standard cXML format, e.g. |
static java.lang.String |
tocXML(java.util.Date date,
java.util.TimeZone timezone)
Returns a string representing the given Date in a
standard cXML format, e.g. |
static java.lang.String |
toDateMonthYearString(java.util.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 java.lang.String |
toDateMonthYearString(java.util.Date date,
java.util.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 java.lang.String |
toDateMonthYearString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone timezone)
|
static java.lang.String |
toDayDateMonthYearString(java.util.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 java.lang.String |
toDayDateMonthYearString(java.util.Date date,
java.util.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 java.lang.String |
toDayDateMonthYearString(java.util.Date date,
java.util.Locale locale,
java.util.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 java.lang.String |
toDayOfWeekString(java.util.Date date)
Returns an abbreviated string representation of the day of the week represented by the given Date , e.g. |
static java.lang.String |
toDayOfWeekString(java.util.Date date,
java.util.Locale locale)
Returns an abbreviated string representation of the day of the week represented by the given Date , e.g. |
static java.lang.String |
toFileTimeString(java.util.Date date)
|
static java.lang.String |
toFullDateMonthYearString(java.util.Date date)
Returns a string representation of the given Date which
includes the full month, day of month, year and time, e.g. |
static java.lang.String |
toFullDateMonthYearString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the given Date which
includes the full month, day of month, year and time, e.g. |
static java.lang.String |
toFullDateMonthYearTZString(java.util.Date date,
java.util.Locale locale,
java.util.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 java.lang.String |
toFullDayDateMonthYearString(java.util.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 java.lang.String |
toFullDayDateMonthYearString(java.util.Date date,
java.util.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 java.lang.String |
toFullDayDateMonthYearString(java.util.Date date,
java.util.Locale locale,
java.util.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 java.lang.String |
toFullDayDateMonthYearTZString(java.util.Date date,
java.util.Locale locale,
java.util.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 java.lang.String |
toGMT(java.util.Date date)
Returns a string representing the given Date in a
standard GMT format, e.g. |
static java.lang.String |
toHourMinSecString(java.util.Date date)
Returns a string representation of the time portion of the given Date which includes hours, minutes and seconds, e.g. |
static java.lang.String |
toHourMinSecString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the time portion of the given Date which includes hours, minutes and seconds, e.g. |
static java.lang.String |
toJavaFormat(java.util.Date date)
|
static java.lang.String |
toJavaFormat(java.util.Date date,
java.util.Locale locale)
|
static java.lang.String |
toLongDayDateMonthYearString(java.util.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 java.lang.String |
toLongDayDateMonthYearString(java.util.Date date,
java.util.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 java.lang.String |
toMilitaryTimeString(java.util.Date date)
Returns a string representation of the time portion of the given Date in military time format, e.g. |
static java.lang.String |
toPaddedConciseDateString(java.util.Date date)
Returns a string representation of the date portion of the given Date in a concise, padded format, e.g. |
static java.lang.String |
toPaddedConciseDateString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the date portion of the given Date in a concise, padded format, e.g. |
static java.lang.String |
toPaddedConciseDateString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a string representation of the date portion of the given Date in a concise, padded format, e.g. |
static java.lang.String |
toPaddedConciseDateTimeString(java.util.Date date)
Returns a string representation of the date and time for the given Date in a concise, padded format, e.g. |
static java.lang.String |
toPaddedConciseDateTimeString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the date and time for the given Date in a concise, padded format, e.g. |
static java.lang.String |
toPaddedConciseDateTimeString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a string representation of the date and time for the given Date in a concise, padded format, e.g. |
static java.lang.String |
toPaddedDateTimeString(java.util.Date date)
Returns a string representation of the date and time for the given DateTime in a padded format, e.g. |
static java.lang.String |
toPaddedDateTimeString(java.util.Date date,
java.util.Locale locale)
Returns a string representation of the date and time for the given DateTime in a padded format, e.g. |
static java.lang.String |
toPaddedDateTimeString(java.util.Date date,
java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a string representation of the date and time for the given DateTime in a padded format, e.g. |
static java.lang.String |
toUTC(java.util.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 java.lang.String |
toYearMonthDate(java.util.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, makeParseException, makeParseExceptionMessage, makeParseExceptionMessage, 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 java.lang.String ClassName
public static final java.lang.String DefaultFormatKey
public static final java.lang.String ConciseDateFormatKey
public static final java.lang.String PaddedConciseDateFormatKey
public static final java.lang.String ConciseDateTimeFormatKey
public static final java.lang.String PaddedConciseDateTimeFormatKey
public static final java.lang.String PaddedDateTimeFormatKey
public static final java.lang.String DayDateMonthYearFormatKey
public static final java.lang.String DateMonthYearFormatKey
public static final java.lang.String FullDateMonthYearFormatKey
public static final java.lang.String FullDateMonthYearTZFormatKey
public static final java.lang.String LongDayDateMonthYearFormatKey
public static final java.lang.String FullDayDateMonthYearFormatKey
public static final java.lang.String FullDayDateMonthYearTZFormatKey
public static final java.lang.String CannotParseDateKey
Constructor Detail |
---|
public DateFormatter()
DateFormatter
.
Method Detail |
---|
public static java.lang.String getStringValue(java.util.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 java.lang.String getStringValue(java.util.Date date, java.util.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 java.lang.String getStringValue(java.util.Date date, java.util.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 java.lang.String getStringValue(java.util.Date date, java.util.Locale locale, java.util.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 java.lang.String getStringValue(java.util.Date date, java.lang.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 java.lang.String getStringValue(java.util.Date date, java.lang.String pattern, java.util.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 java.lang.String getStringValue(java.util.Date date, java.lang.String pattern, java.lang.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 java.lang.String getStringValue(java.util.Date date, java.lang.String pattern, java.util.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 java.lang.String getStringValue(java.util.Date date, java.lang.String pattern, java.util.Locale locale, java.util.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 java.lang.String getDateString(java.util.Date date, java.util.Locale locale, java.util.TimeZone timeZone)
public java.lang.String getDateString(java.util.Date date, java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timeZone)
public static java.lang.String getStringValueUsingFormats(java.util.Date date, java.lang.String formatsKey, java.util.Locale locale, java.util.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.
Date
public static java.lang.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 java.lang.String toConciseDateString(java.util.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 java.lang.String toConciseDateString(java.util.Date date, java.util.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 java.lang.String toConciseDateString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toPaddedConciseDateString(java.util.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 java.lang.String toPaddedConciseDateString(java.util.Date date, java.util.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 java.lang.String toPaddedConciseDateString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toConciseDateTimeString(java.util.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 java.lang.String toConciseDateTimeString(java.util.Date date, java.util.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 java.lang.String toConciseDateTimeString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toPaddedConciseDateTimeString(java.util.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 java.lang.String toPaddedConciseDateTimeString(java.util.Date date, java.util.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 java.lang.String toPaddedConciseDateTimeString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toPaddedDateTimeString(java.util.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 java.lang.String toPaddedDateTimeString(java.util.Date date, java.util.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 java.lang.String toPaddedDateTimeString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toDayDateMonthYearString(java.util.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 java.lang.String toDayDateMonthYearString(java.util.Date date, java.util.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 java.lang.String toDayDateMonthYearString(java.util.Date date, java.util.Locale locale, java.util.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.
Date
public static java.lang.String toLongDayDateMonthYearString(java.util.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 java.lang.String toLongDayDateMonthYearString(java.util.Date date, java.util.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
Date
public static java.lang.String toFullDayDateMonthYearString(java.util.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 java.lang.String toFullDayDateMonthYearString(java.util.Date date, java.util.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 java.lang.String toFullDayDateMonthYearString(java.util.Date date, java.util.Locale locale, java.util.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 java.lang.String toFullDayDateMonthYearTZString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toDateMonthYearString(java.util.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 java.lang.String toDateMonthYearString(java.util.Date date, java.util.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
Date
public static java.lang.String toDateMonthYearString(java.util.Date date, java.util.Locale locale, java.util.TimeZone timezone)
public static java.lang.String toFullDateMonthYearString(java.util.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 java.lang.String toFullDateMonthYearString(java.util.Date date, java.util.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 java.lang.String toFullDateMonthYearTZString(java.util.Date date, java.util.Locale locale, java.util.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
Date
public static java.lang.String toHourMinSecString(java.util.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 java.lang.String toHourMinSecString(java.util.Date date, java.util.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
Date
public static java.lang.String toDayOfWeekString(java.util.Date date)
Date
, e.g. "Mon", "Tue", etc.
date
- the Date
to format
Date
public static java.lang.String toDayOfWeekString(java.util.Date date, java.util.Locale locale)
Date
, e.g. "Mon", "Tue", etc.
date
- the Date
to formatlocale
- the Locale
to use for formatting
Date
public static java.lang.String toGMT(java.util.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
Date
public static java.lang.String toYearMonthDate(java.util.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
Date
public static java.lang.String toMilitaryTimeString(java.util.Date date)
Date
in military time format, e.g. "21:05:35". This
format is not locale-specific.
date
- the Date
to format
Date
public static java.lang.String toFileTimeString(java.util.Date date)
public static java.lang.String toJavaFormat(java.util.Date date)
public static java.lang.String toJavaFormat(java.util.Date date, java.util.Locale locale)
public static java.lang.String toUTC(java.util.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
Date
public static java.lang.String tocXML(java.util.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 java.lang.String tocXML(java.util.Date date, java.util.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 java.lang.String getTimePatternEquivalentToSunFormat(int style, java.util.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 java.lang.String getDatePatternEquivalentToSunFormat(int style, java.util.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 java.lang.String getDateTimePatternEquivalentToSunFormat(int style, java.util.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(java.lang.String string) throws java.text.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
java.text.ParseException
- if the string can't be parsed as a
Date
parseDate(java.lang.String, java.lang.String)
,
parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String)
public static Date parseDate(java.lang.String string, boolean calendarDate) throws java.text.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 Date
calendarDate
- if true, a calendar date will be created
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
parseDate(String, String, boolean)
,
parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String, boolean)
public static Date parseDate(java.lang.String string, java.util.Locale locale) throws java.text.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 Date
locale
- the Locale
to use for parsing, must not be null
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
parseDate(String,String,java.util.Locale)
,
parseDateUsingFormats(String,java.util.Locale,String)
public static Date parseDate(java.lang.String string, java.util.Locale locale, boolean calendarDate) throws java.text.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 Date
locale
- the Locale
to use for parsing, must not be nullcalendarDate
- if true, a calendar date will be created
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
parseDate(String, String, java.util.Locale, boolean)
,
parseDateUsingFormats(String,java.util.Locale,String,boolean)
public static Date parseDate(java.lang.String string, java.util.Locale locale, java.util.TimeZone timeZone, boolean calendarDate) throws java.text.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 Date
locale
- 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
java.text.ParseException
- if the string can't be parsed as a
Date
parseDate(String,String,java.util.Locale,java.util.TimeZone,boolean)
,
boolean calendarDate)
public static Date parseDateUsingFormats(java.lang.String string, java.util.Locale locale, java.lang.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 Date
locale
- 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(java.lang.String string, java.util.Locale locale, java.lang.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 Date
locale
- 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(java.lang.String string, java.util.Locale locale, java.lang.String formatsKey, java.util.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 Date
locale
- 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(java.lang.String string, java.lang.String pattern) throws java.text.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 Date
pattern
- the date format pattern to use for parsing in the
default lcoale
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
using the given format patternpublic static Date parseDate(java.lang.String string, java.lang.String pattern, boolean calendarDate) throws java.text.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 Date
pattern
- 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
java.text.ParseException
- if the string can't be parsed as a
Date
using the given format patternpublic static Date parseDate(java.lang.String string, java.lang.String pattern, java.util.Locale locale) throws java.text.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 Date
pattern
- the date format pattern to use for parsing for the specified localelocale
- the Locale
to use for parsing
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
using the given format patternpublic static Date parseDate(java.lang.String string, java.lang.String pattern, java.util.Locale locale, boolean calendarDate) throws java.text.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 Date
pattern
- 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
java.text.ParseException
- if the string can't be parsed as a
Date
using the given format patternpublic static Date parseDate(java.lang.String string, java.lang.String pattern, java.util.Locale locale, java.util.TimeZone timeZone, boolean calendarDate) throws java.text.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 Date
pattern
- 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
java.text.ParseException
- if the string can't be parsed as a
Date
using the given format patternpublic static Date parseDateGMT(java.lang.String string) throws java.text.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
java.text.ParseException
- if the string can't be parsed as a
Date
using a GMT format patternpublic static java.util.TimeZone getDefaultTimeZone()
public static java.util.Locale getDefaultLocale()
public static Date parseDateUTC(java.lang.String dateStr) throws java.text.ParseException
Date
.
Uses the UTC date pattern as the parsing template.
dateStr
- the string to parse as a Date
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
using the UTC format patternpublic static Date parseDateCXML(java.lang.String string) throws java.text.ParseException
Date
.
Uses the cXML date pattern as the parsing template.
Ignores milliseconds part of the date.
string
- the string to parse as a Date
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
using the cXML GMT format patternpublic static Date parseDateCXMLWithMs(java.lang.String string, boolean addMillisecondValue) throws java.text.ParseException
Date
.
Uses the cXML date pattern as the parsing template.
string
- the string to parse as a Date
addMillisecondValue
- if true, milliseconds are going to be added to the result
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
using the cXML GMT format patternpublic static int getMillisecondsTest(java.lang.String s) throws java.text.ParseException
java.text.ParseException
public static Date getDateValue(java.lang.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 Date
calendarDate
- if true, a calendar date will be created
Date
derived from the given objectpublic static Date getDateValue(java.lang.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 objectpublic static Date getDateValue(java.lang.Object object, java.util.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 Date
locale
- the Locale
to use for conversion
Date
derived from the given objectpublic static Date getDateValue(java.lang.Object object, java.util.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 Date
locale
- 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 objectpublic static int compareDates(java.util.Date d1, java.util.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 orderedpublic java.lang.Object parseString(java.lang.String string, java.util.Locale locale) throws java.text.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
java.text.ParseException
- if the string can't be parsed as a
Date
object in the given localepublic java.lang.Object parseString(java.lang.String string, java.util.Locale locale, java.util.TimeZone tz) throws java.text.ParseException
Date
in the given
locale and time zone.
string
- the string to parse as a Date
locale
- the Locale
to use for parsingtz
- the TimeZone
to use for parsing
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
public java.lang.Object parseString(java.lang.String string, java.util.Locale locale, java.util.TimeZone tz, boolean calendarDate) throws java.text.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 Date
locale
- 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
java.text.ParseException
- if the string can't be parsed as a
Date
public java.lang.Object getValue(java.lang.Object object, java.util.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 Formatter
object
- the object to convert to a Date
locale
- 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 |