public class StdDateFormat extends DateFormat
DateFormat implementation used by standard Date
serializers and deserializers. For serialization defaults to using
an ISO-8601 compliant format (format String "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
and for deserialization, both ISO-8601 and RFC-1123.
Note also that to enable use of colon in timezone is possible by using method
withColonInTimeZone(boolean) for creating new differently configured format instance.
DateFormat.Field| Modifier and Type | Field and Description |
|---|---|
static String |
DATE_FORMAT_STR_ISO8601
Defines a commonly used date format that conforms
to ISO-8601 date formatting standard, when it includes basic undecorated
timezone definition.
|
static StdDateFormat |
instance
A singleton instance can be used for cloning purposes, as a blueprint of sorts.
|
AM_PM_FIELD, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD| Constructor and Description |
|---|
StdDateFormat() |
StdDateFormat(TimeZone tz,
Locale loc)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
StdDateFormat |
clone() |
boolean |
equals(Object o) |
StringBuffer |
format(Date date,
StringBuffer toAppendTo,
FieldPosition fieldPosition) |
static TimeZone |
getDefaultTimeZone() |
static DateFormat |
getISO8601Format(TimeZone tz,
Locale loc)
Deprecated.
Since 2.9
|
static DateFormat |
getRFC1123Format(TimeZone tz,
Locale loc)
Deprecated.
Since 2.9
|
TimeZone |
getTimeZone() |
int |
hashCode() |
boolean |
isColonIncludedInTimeZone()
Accessor for checking whether this instance would include colon
within timezone serialization or not: if {code true}, timezone offset
is serialized like
-06:00; if {code false} as -0600. |
boolean |
isLenient() |
Date |
parse(String dateStr) |
Date |
parse(String dateStr,
ParsePosition pos) |
void |
setLenient(boolean enabled)
Need to override since we need to keep track of leniency locally,
and not via underlying
Calendar instance like base class
does. |
void |
setTimeZone(TimeZone tz) |
String |
toPattern() |
String |
toString() |
StdDateFormat |
withColonInTimeZone(boolean b)
"Mutant factory" method that will return an instance that has specified
handling of colon when serializing timezone (timezone either written
like
+0500 or +05:00):
either this instance (if setting would not change), or newly
constructed instance with desired setting for colon inclusion. |
StdDateFormat |
withLenient(Boolean b)
"Mutant factory" method that will return an instance that has specified leniency
setting: either
this instance (if setting would not change), or newly
constructed instance. |
StdDateFormat |
withLocale(Locale loc)
"Mutant factory" method that will return an instance that uses specified
Locale:
either this instance (if setting would not change), or newly
constructed instance with different Locale to use. |
StdDateFormat |
withTimeZone(TimeZone tz)
Method used for creating a new instance with specified timezone;
if no timezone specified, defaults to the default timezone (UTC).
|
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, parseObject, setCalendar, setNumberFormatformat, formatToCharacterIterator, parseObjectpublic static final String DATE_FORMAT_STR_ISO8601
public static final StdDateFormat instance
public StdDateFormat()
@Deprecated public StdDateFormat(TimeZone tz, Locale loc)
public static TimeZone getDefaultTimeZone()
public StdDateFormat withTimeZone(TimeZone tz)
public StdDateFormat withLocale(Locale loc)
Locale:
either this instance (if setting would not change), or newly
constructed instance with different Locale to use.public StdDateFormat withLenient(Boolean b)
this instance (if setting would not change), or newly
constructed instance.public StdDateFormat withColonInTimeZone(boolean b)
+0500 or +05:00):
either this instance (if setting would not change), or newly
constructed instance with desired setting for colon inclusion.
NOTE: does NOT affect deserialization as colon is optional accepted but not required -- put another way, either serialization is accepted by this class.
public StdDateFormat clone()
clone in class DateFormat@Deprecated public static DateFormat getISO8601Format(TimeZone tz, Locale loc)
@Deprecated public static DateFormat getRFC1123Format(TimeZone tz, Locale loc)
public TimeZone getTimeZone()
getTimeZone in class DateFormatpublic void setTimeZone(TimeZone tz)
setTimeZone in class DateFormatpublic void setLenient(boolean enabled)
Calendar instance like base class
does.setLenient in class DateFormatpublic boolean isLenient()
isLenient in class DateFormatpublic boolean isColonIncludedInTimeZone()
-06:00; if {code false} as -0600.
NOTE: only relevant for serialization (formatting), as deserialization (parsing) always accepts optional colon but does not require it, regardless of this setting.
true if a colon is to be inserted between the hours and minutes
of the TZ offset when serializing as String; otherwise falsepublic Date parse(String dateStr) throws ParseException
parse in class DateFormatParseExceptionpublic Date parse(String dateStr, ParsePosition pos)
parse in class DateFormatpublic StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
format in class DateFormatpublic String toPattern()
public boolean equals(Object o)
equals in class DateFormatpublic int hashCode()
hashCode in class DateFormatCopyright © 2010 - 2020 Adobe. All Rights Reserved