ariba.util.formatter
Class DateFormatter

java.lang.Object
  extended by ariba.util.formatter.Formatter
      extended by ariba.util.formatter.DateFormatter
All Implemented Interfaces:
Compare, StringParser
Direct Known Subclasses:
UserDateFormatter

public class DateFormatter
extends Formatter

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

ClassName

public static final java.lang.String ClassName
Our Java class name.

See Also:
Constant Field Values

DefaultFormatKey

public static final java.lang.String DefaultFormatKey
localized resource string tag for the default date format pattern. See resource.date.csv.

See Also:
Constant Field Values

ConciseDateFormatKey

public static final java.lang.String ConciseDateFormatKey
Format key for unpadded concise date format strings. See resource.date.csv.

See Also:
Constant Field Values

PaddedConciseDateFormatKey

public static final java.lang.String PaddedConciseDateFormatKey
Format key for padded concise date format strings. See resource.date.csv.

See Also:
Constant Field Values

ConciseDateTimeFormatKey

public static final java.lang.String ConciseDateTimeFormatKey
Format key for unpadded concise date/time format strings. See resource.date.csv.

See Also:
Constant Field Values

PaddedConciseDateTimeFormatKey

public static final java.lang.String PaddedConciseDateTimeFormatKey
Format key for padded concise date/time format strings. See resource.date.csv.

See Also:
Constant Field Values

PaddedDateTimeFormatKey

public static final java.lang.String PaddedDateTimeFormatKey
Format key for padded concise date/time format strings. See resource.date.csv.

See Also:
Constant Field Values

DayDateMonthYearFormatKey

public static final java.lang.String DayDateMonthYearFormatKey
Format key for medium length date format strings (for printing). See resource.date.csv.

See Also:
Constant Field Values

DateMonthYearFormatKey

public static final java.lang.String DateMonthYearFormatKey
Format key for medium length date format strings (for printing). See resource.date.csv.

See Also:
Constant Field Values

FullDateMonthYearFormatKey

public static final java.lang.String FullDateMonthYearFormatKey
Format key for date format strings (for printing). See resource.date.csv.

See Also:
Constant Field Values

FullDateMonthYearTZFormatKey

public static final java.lang.String FullDateMonthYearTZFormatKey
Format key for date format strings with time zone(for printing). See resource.date.csv.

See Also:
Constant Field Values

LongDayDateMonthYearFormatKey

public static final java.lang.String LongDayDateMonthYearFormatKey
Format key for long date format strings. See resource.date.csv.

See Also:
Constant Field Values

FullDayDateMonthYearFormatKey

public static final java.lang.String FullDayDateMonthYearFormatKey
Format key for full date format strings. See resource.date.csv.

See Also:
Constant Field Values

FullDayDateMonthYearTZFormatKey

public static final java.lang.String FullDayDateMonthYearTZFormatKey
Format key for full date format strings with time zone. See resource.date.csv.

See Also:
Constant Field Values

CannotParseDateKey

public static final java.lang.String CannotParseDateKey
See Also:
Constant Field Values
Constructor Detail

DateFormatter

public DateFormatter()
Creates a new DateFormatter.

Method Detail

getStringValue

public static java.lang.String getStringValue(java.util.Date date)
Returns a formatted string for the given 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.

Parameters:
date - the Date to format into a string
Returns:
a string representation of the Date

getStringValue

public 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. 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.

Parameters:
date - the Date to format into a string
locale - the Locale to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. 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.

Parameters:
date - the Date to format into a string
timeZone - the TimeZone to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. 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.

Parameters:
date - the Date to format into a string
locale - the Locale to use for formatting
timeZone - the TimeZone to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. Uses the date format pattern pattern as the template for how the date should be formatted.

Parameters:
date - the Date to format into a string
pattern - the locale-specific date format pattern to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. Uses the date format pattern pattern as the template for how the date should be formatted.

Parameters:
date - the Date to format into a string
pattern - the locale-specific date format pattern to use for formatting
locale - the Locale to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. 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.

Parameters:
date - the Date to format into a string
pattern - the locale-specific date format pattern to use for formatting
tzString - the identifier of the time zone to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. Uses the date format pattern pattern as the template for how the date should be formatted. Uses the given timeZone to format the date.

Parameters:
date - the Date to format into a string
pattern - the date format pattern to use for formatting
timeZone - the TimeZone to use for formatting
Returns:
a string representation of the Date

getStringValue

public 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. 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.

Parameters:
date - the Date to format into a string
pattern - the date format pattern to use for formatting
locale - the Locale to use for formatting
timeZone - the TimeZone to use for formatting
Returns:
a string representation of the Date

getDateString

public java.lang.String getDateString(java.util.Date date,
                                      java.util.Locale locale,
                                      java.util.TimeZone timeZone)

getDateString

public java.lang.String getDateString(java.util.Date date,
                                      java.lang.String pattern,
                                      java.util.Locale locale,
                                      java.util.TimeZone timeZone)

getStringValueUsingFormats

public 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. 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.

Parameters:
date - the Date to format into a string
formatsKey - 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.
Returns:
a string representation of the Date

formatMillisAsDuration

public static java.lang.String formatMillisAsDuration(long millis)
Formats the given 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".


toConciseDateString

public 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. "1/12/1999". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toConciseDateString

public 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. "1/12/1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toConciseDateString

public 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. "1/12/1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
tz - the TimeZone, to use for formatting
Returns:
a string representation of the Date

toPaddedConciseDateString

public 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. "01/12/1999". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toPaddedConciseDateString

public 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. "01/12/1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toPaddedConciseDateString

public 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. "01/12/1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
tz - the TimeZone, to use for formatting
Returns:
a string representation of the Date

toConciseDateTimeString

public 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. "1/12/1999 3:14 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toConciseDateTimeString

public 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. "1/12/1999 3:14 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toConciseDateTimeString

public 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. "1/12/1999 3:14 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
timeZone - the TimeZone, to use for formatting
Returns:
a string representation of the Date

toPaddedConciseDateTimeString

public 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. "01/12/1999 03:14 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toPaddedConciseDateTimeString

public 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. "01/12/1999 03:14 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toPaddedConciseDateTimeString

public 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. "01/12/1999 03:14 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
timeZone - the TimeZone, to use for formatting
Returns:
a string representation of the Date

toPaddedDateTimeString

public 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. "01/12/1999 03:14:34 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toPaddedDateTimeString

public 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. "01/12/1999 03:14:34 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toPaddedDateTimeString

public 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. "01/12/1999 03:14:34 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
timeZone - the TimeZone, to use for formatting
Returns:
a string representation of the Date

toDayDateMonthYearString

public 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. "Mon, 02 Jun, 1999". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toDayDateMonthYearString

public 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. "Mon, 02 Jun, 1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toDayDateMonthYearString

public 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. "Mon, 02 Jun, 1999". The exact format is locale-specific.

Parameters:
date - date the Date to format
locale - locale the Locale to use for formatting
tz - Time zone.
Returns:
a string representation of the Date

toLongDayDateMonthYearString

public 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. "Monday, January 31, 1999". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toLongDayDateMonthYearString

public 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. "Monday, January 31, 1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toFullDayDateMonthYearString

public 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. "Monday, January 31, 1999 at 3:15 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toFullDayDateMonthYearString

public 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. "Monday, January 31, 1999 at 3:15 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toFullDayDateMonthYearString

public 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. "Monday, January 31, 1999 at 3:15 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
tz - the TimeZone to use for formatting
Returns:
a string representation of the Date

toFullDayDateMonthYearTZString

public 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. "Monday, January 31, 1999 at 3:15 PM, Pacific Daylight Time". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
tz - the TimeZone to use for formatting
Returns:
a string representation of the Date

toDateMonthYearString

public 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. "January 31, 1999". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toDateMonthYearString

public 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. "January 31, 1999". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toDateMonthYearString

public static java.lang.String toDateMonthYearString(java.util.Date date,
                                                     java.util.Locale locale,
                                                     java.util.TimeZone timezone)

toFullDateMonthYearString

public 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. "January 31, 1999 at 3:15 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toFullDateMonthYearString

public 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. "January 31, 1999 at 3:15 PM". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toFullDateMonthYearTZString

public 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. "January 31, 1999 at 3:15 PM Pacific Daylight Time". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
tz - the TimeZone to use for formatting
Returns:
a string representation of the Date

toHourMinSecString

public 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. "3:01:42". The exact format is locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toHourMinSecString

public 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. "3:01:42". The exact format is locale-specific.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toDayOfWeekString

public 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. "Mon", "Tue", etc.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toDayOfWeekString

public 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. "Mon", "Tue", etc.

Parameters:
date - the Date to format
locale - the Locale to use for formatting
Returns:
a string representation of the Date

toGMT

public static java.lang.String toGMT(java.util.Date date)
Returns a string representing the given 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.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toYearMonthDate

public 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. "19990521". This format is not locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toMilitaryTimeString

public 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. "21:05:35". This format is not locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

toFileTimeString

public static java.lang.String toFileTimeString(java.util.Date date)

toJavaFormat

public static java.lang.String toJavaFormat(java.util.Date date)

toJavaFormat

public static java.lang.String toJavaFormat(java.util.Date date,
                                            java.util.Locale locale)

toUTC

public 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. "2003-08-30T03:01:39Z". This format is not locale-specific.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

tocXML

public static java.lang.String tocXML(java.util.Date date)
Returns a string representing the given 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.

Parameters:
date - the Date to format
Returns:
a string representation of the Date

tocXML

public 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. "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.

Parameters:
date - the Date to format
timezone - the TimeZone to used. If null, DateFormatter.getDefaultTimeZone() will be used.
Returns:
a string representation of the Date

getTimePatternEquivalentToSunFormat

public 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. 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.

Parameters:
style - date format as defined by Sun
locale - locale to use to look up the date format
Returns:
a valid date format matching the Sun's constant

getDatePatternEquivalentToSunFormat

public 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. 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.

Parameters:
style - date format as defined by Sun
locale - locale to use to look up the date format
Returns:
a valid date format matching the Sun's constant

getDateTimePatternEquivalentToSunFormat

public 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. 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.

Parameters:
style - date format as defined by Sun
locale - locale to use to look up the date format
Returns:
a valid date format matching the Sun's constant

parseDate

public static Date parseDate(java.lang.String string)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date
See Also:
parseDate(java.lang.String, java.lang.String), parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String)

parseDate

public static Date parseDate(java.lang.String string,
                             boolean calendarDate)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date
See Also:
parseDate(String, String, boolean), parseDateUsingFormats(java.lang.String, java.util.Locale, java.lang.String, boolean)

parseDate

public static Date parseDate(java.lang.String string,
                             java.util.Locale locale)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
locale - the Locale to use for parsing, must not be null
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date
See Also:
parseDate(String,String,java.util.Locale), parseDateUsingFormats(String,java.util.Locale,String)

parseDate

public static Date parseDate(java.lang.String string,
                             java.util.Locale locale,
                             boolean calendarDate)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
locale - the Locale to use for parsing, must not be null
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date
See Also:
parseDate(String, String, java.util.Locale, boolean), parseDateUsingFormats(String,java.util.Locale,String,boolean)

parseDate

public static Date parseDate(java.lang.String string,
                             java.util.Locale locale,
                             java.util.TimeZone timeZone,
                             boolean calendarDate)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
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
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date
See Also:
parseDate(String,String,java.util.Locale,java.util.TimeZone,boolean), boolean calendarDate)

parseDateUsingFormats

public 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. Uses the given formatsKey to look up a string which is the list of date formats to use to try and parse the string as a date.

Parameters:
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
Returns:
a Date derived from the string, null if the sting cannot be parsed.

parseDateUsingFormats

public 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. Uses the given formatsKey to look up a string which is the list of date formats to use to try and parse the string as a date.

Parameters:
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
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string, null if the sting cannot be parsed.

parseDateUsingFormats

public 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. Uses the given formatsKey to look up a string which is the list of date formats to use to try and parse the string as a date.

Parameters:
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
timeZone - the TimeZone to use for parsing, must be non-null.
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string, null if the sting cannot be parsed.

parseDate

public static Date parseDate(java.lang.String string,
                             java.lang.String pattern)
                      throws java.text.ParseException
Tries to parse the given string as a Date in the default locale and time zone. Uses the date format pattern pattern as the template for how the date should be parsed.

Parameters:
string - the string to parse as a Date
pattern - the date format pattern to use for parsing in the default lcoale
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the given format pattern

parseDate

public static Date parseDate(java.lang.String string,
                             java.lang.String pattern,
                             boolean calendarDate)
                      throws java.text.ParseException
Tries to parse the given string as a Date in the default locale and time zone. Uses the date format pattern pattern as the template for how the date should be parsed.

Parameters:
string - the string to parse as a Date
pattern - the date format pattern to use for parsing in the default locale
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the given format pattern

parseDate

public static Date parseDate(java.lang.String string,
                             java.lang.String pattern,
                             java.util.Locale locale)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
pattern - the date format pattern to use for parsing for the specified locale
locale - the Locale to use for parsing
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the given format pattern

parseDate

public static Date parseDate(java.lang.String string,
                             java.lang.String pattern,
                             java.util.Locale locale,
                             boolean calendarDate)
                      throws java.text.ParseException
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
pattern - the date format pattern to use for parsing for the specified locale
locale - the Locale to use for parsing
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the given format pattern

parseDate

public 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
Tries to parse the given string as a 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.

Parameters:
string - the string to parse as a Date
pattern - the date format pattern to use for parsing for the specified locale
locale - the Locale to use for parsing
timeZone - the TimeZone to use for parsing
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the given format pattern

parseDateGMT

public static Date parseDateGMT(java.lang.String string)
                         throws java.text.ParseException
Tries to parse the given GMT date string (e.g. "12 Aug 1995 02:30:00 GMT") as a Date in the default locale and time zone. Uses the GMT date format pattern as the parsing template.

Parameters:
string - the string to parse as a Date
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using a GMT format pattern

getDefaultTimeZone

public static java.util.TimeZone getDefaultTimeZone()

getDefaultLocale

public static java.util.Locale getDefaultLocale()
Returns the default locale to use for formatting, parsing, etc. if no locale is given explicitly in one of the static methods above. The locale from the current resource service is used as a default.

Returns:
Returns the default locale

parseDateUTC

public static Date parseDateUTC(java.lang.String dateStr)
                         throws java.text.ParseException
Tries to parse the given UTC date string (e.g. e.g. "2003-08-30T03:01:39Z") as a Date. Uses the UTC date pattern as the parsing template.

Parameters:
dateStr - the string to parse as a Date
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the UTC format pattern

parseDateCXML

public static Date parseDateCXML(java.lang.String string)
                          throws java.text.ParseException
Tries to parse the given cXML date string (e.g. "1999-03-12T18:39:09-08:00" or "1999-03-12T18:39:09.123-08:00") as a Date. Uses the cXML date pattern as the parsing template. Ignores milliseconds part of the date.

Parameters:
string - the string to parse as a Date
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the cXML GMT format pattern

parseDateCXMLWithMs

public static Date parseDateCXMLWithMs(java.lang.String string,
                                       boolean addMillisecondValue)
                                throws java.text.ParseException
Tries to parse the given cXML date string (e.g. "1999-03-12T18:39:09-08:00" or "1999-03-12T18:39:09.123-08:00") as a Date. Uses the cXML date pattern as the parsing template.

Parameters:
string - the string to parse as a Date
addMillisecondValue - if true, milliseconds are going to be added to the result
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date using the cXML GMT format pattern

getMillisecondsTest

public static int getMillisecondsTest(java.lang.String s)
                               throws java.text.ParseException
Throws:
java.text.ParseException

getDateValue

public static Date getDateValue(java.lang.Object object,
                                boolean calendarDate)
Returns a new 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.

Parameters:
object - the object to convert to a Date
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the given object

getDateValue

public static Date getDateValue(java.lang.Object object)
Returns a new 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.

Parameters:
object - the object to convert to a Date
Returns:
a Date derived from the given object

getDateValue

public static Date getDateValue(java.lang.Object object,
                                java.util.Locale locale)
Returns a new 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.

Parameters:
object - the object to convert to a Date
locale - the Locale to use for conversion
Returns:
a Date derived from the given object

getDateValue

public 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. 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.

Parameters:
object - the object to convert to a Date
locale - the Locale to use for conversion
calendarDate - if true, and the Date must be parsed from the object, a calendar date will be created
Returns:
a Date derived from the given object

compareDates

public static int compareDates(java.util.Date d1,
                               java.util.Date d2)
Compares two 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.

Parameters:
d1 - the first Date to compare
d2 - the second Date to compare
Returns:
int value which determines how the two objects should be ordered

parseString

public java.lang.Object parseString(java.lang.String string,
                                    java.util.Locale locale)
                             throws java.text.ParseException
Tries to parse the given string into a Date object in the given locale. The string is assumed to be non-null and trimmed of leading and trailing whitespace.

Parameters:
string - the string to parse
locale - the Locale to use for parsing
Returns:
a Date object derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date object in the given locale

parseString

public java.lang.Object parseString(java.lang.String string,
                                    java.util.Locale locale,
                                    java.util.TimeZone tz)
                             throws java.text.ParseException
Parse the given string as a Date in the given locale and time zone.

Parameters:
string - the string to parse as a Date
locale - the Locale to use for parsing
tz - the TimeZone to use for parsing
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date

parseString

public java.lang.Object parseString(java.lang.String string,
                                    java.util.Locale locale,
                                    java.util.TimeZone tz,
                                    boolean calendarDate)
                             throws java.text.ParseException
Parse the given string as a Date in the given locale and time zone. The locale and timeZone parameters must be non-null.

Parameters:
string - the string to parse as a Date
locale - the Locale to use for parsing
tz - the TimeZone to use for parsing
calendarDate - if true, a calendar date will be created
Returns:
a Date derived from the string
Throws:
java.text.ParseException - if the string can't be parsed as a Date

getValue

public 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. 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.

Specified by:
getValue in class Formatter
Parameters:
object - the object to convert to a Date
locale - the Locale to use for conversion
Returns:
a Date derived from the given object


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.