|
|||||||||
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
ariba.util.formatter.UserDateFormatter
public class UserDateFormatter
UserDateFormatter
is a subclass of DateFormatter
which is responsible for parsing user date strings, i.e. string typed in
or selected by the user. Additional natural language processing is done
to make date input more user-friendly. The localized strings for "today",
"tomorrow", and "yesterday" are recognized and converted to the
appropriate date relative to the current date. Day of week strings
(e.g. "monday", "sunday", etc.) are also supported for input.
Field Summary | |
---|---|
static java.lang.String |
ClassName
Our Java class name. |
Fields inherited from interface ariba.util.core.Compare |
---|
EqualTo, GreaterThan, LessThan |
Constructor Summary | |
---|---|
UserDateFormatter()
Creates a new UserDateFormatter . |
Method Summary | |
---|---|
java.lang.String |
getDateString(Date date,
java.util.Locale locale,
java.util.TimeZone timeZone)
|
static java.lang.String |
getStringValue(Date date)
Returns a formatted string for the given Date in the
default locale. |
static java.lang.String |
getStringValue(Date date,
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(Date date,
java.util.TimeZone timeZone)
Returns a formatted string for the given Date in the
given timeZone using the default locale. |
java.lang.Object |
getValue(java.lang.Object object,
java.util.Locale locale)
Overrides DateFormatter.parseString() to call our static method for converting an object into a date. |
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 Date |
parseUserDate(java.lang.String string)
Tries to parse the given user string as a Date in the
default locale. |
static Date |
parseUserDate(java.lang.String string,
boolean calendarDate)
Tries to parse the given user string as a Date in the
default locale. |
static Date |
parseUserDate(java.lang.String string,
java.util.Locale locale)
Tries to parse the given user string as a Date in the
given locale. |
static Date |
parseUserDate(java.lang.String string,
java.util.Locale locale,
boolean calendarDate)
Tries to parse the given user string as a Date in the
given locale. |
static Date |
parseUserDate(java.lang.String string,
java.util.Locale locale,
java.util.TimeZone tz,
boolean calendarDate)
Tries to parse the given user string as a Date in the
given locale. |
static Date |
userDateValue(java.lang.Object object)
Returns a new Date derived from the given object in the
default locale. |
static Date |
userDateValue(java.lang.Object object,
boolean calendarDate)
Returns a new Date derived from the given object in the
default locale. |
static Date |
userDateValue(java.lang.Object object,
java.util.Locale locale)
Returns a new Date derived from the given object in the
given locale. |
static Date |
userDateValue(java.lang.Object object,
java.util.Locale locale,
boolean calendarDate)
Returns a new Date derived from the given object in the
given locale. |
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
Constructor Detail |
---|
public UserDateFormatter()
UserDateFormatter
.
Method Detail |
---|
public static java.lang.String getStringValue(Date date)
Date
in the
default locale. Recognizes if the given Date
is today
and formats the output accordingly.
date
- the Date
to format into a string
Date
public static java.lang.String getStringValue(Date date, java.util.TimeZone timeZone)
Date
in the
given timeZone
using the default locale. Recognizes if
the given Date
is today and formats the output
accordingly.
date
- the Date
to format into a stringtimeZone
- the TimeZone
to use for formatting
Date
public static java.lang.String getStringValue(Date date, java.util.Locale locale, java.util.TimeZone timeZone)
Date
in the
given locale. Recognizes if the given Date
is today and
formats the output accordingly.
date
- the Date
to format into a stringlocale
- the Locale
to use for formattingtimeZone
- the TimeZone
to use for formatting
Date
public java.lang.String getDateString(Date date, java.util.Locale locale, java.util.TimeZone timeZone)
public static Date parseUserDate(java.lang.String string, boolean calendarDate) throws java.text.ParseException
Date
in the
default locale. In addition to the default date parsing, this method
will also try to handle a number of more natural date strings,
e.g. the string "today", "tomorrow", "monday", etc. It also handles
cases where the string is incomplete, e.g. "2/21". In this case, the
current year is used as the default.
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
public static Date parseUserDate(java.lang.String string) throws java.text.ParseException
Date
in the
default locale. In addition to the default date parsing, this method
will also try to handle a number of more natural date strings,
e.g. the string "today", "tomorrow", "monday", etc. It also handles
cases where the string is incomplete, e.g. "2/21". In this case, the
current year is used as the default.
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
public static Date parseUserDate(java.lang.String string, java.util.Locale locale) throws java.text.ParseException
Date
in the
given locale. In addition to the default date parsing, this method
will also try to handle a number of more natural date strings,
e.g. the string "today", "tomorrow", "monday", etc. It also handles
cases where the string is incomplete, e.g. "2/21". In this case, the
current year is used as the default.
string
- the string to parse as a Date
locale
- the Locale
to use for parsing
Date
derived from the string
java.text.ParseException
- if the string can't be parsed as a
Date
public static Date parseUserDate(java.lang.String string, java.util.Locale locale, boolean calendarDate) throws java.text.ParseException
Date
in the
given locale. In addition to the default date parsing, this method
will also try to handle a number of more natural date strings,
e.g. the string "today", "tomorrow", "monday", etc. It also handles
cases where the string is incomplete, e.g. "2/21". In this case, the
current year is used as the default.
string
- the string to parse as a Date
locale
- 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
public static Date parseUserDate(java.lang.String string, java.util.Locale locale, java.util.TimeZone tz, boolean calendarDate) throws java.text.ParseException
Date
in the
given locale. In addition to the default date parsing, this method
will also try to handle a number of more natural date strings,
e.g. the string "today", "tomorrow", "monday", etc. It also handles
cases where the string is incomplete, e.g. "2/21". In this case, the
current year is used as the default.
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 static Date userDateValue(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 as a user string. 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 userDateValue(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 as a user string. 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 userDateValue(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 as a user string. 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 userDateValue(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 as a user string. 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, a calendar date will be created
Date
derived from the given objectpublic 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. The locale
and
timeZone
parameters must be non-null.
parseString
in class DateFormatter
string
- the string to parselocale
- the Locale
to use for parsingtz
- the TimeZone
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, boolean calendarDate) throws java.text.ParseException
Date
in the given
locale and time zone. The locale
and
timeZone
parameters must be non-null.
parseString
in class DateFormatter
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)
getValue
in class DateFormatter
object
- the object to convert to a Date
locale
- the Locale
to use for conversion
Date
derived from the string
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |