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.DateFormat.Field| Modifier and Type | Field and Description |
|---|---|
protected Boolean |
_lenient
Explicit override for leniency, if specified.
|
protected Locale |
_locale |
protected TimeZone |
_timezone
Caller may want to explicitly override timezone to use; if so,
we will have non-null value here.
|
protected static String[] |
ALL_FORMATS
For error messages we'll also need a list of all formats.
|
protected static DateFormat |
DATE_FORMAT_ISO8601 |
protected static DateFormat |
DATE_FORMAT_RFC1123 |
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.
|
protected static String |
DATE_FORMAT_STR_PLAIN
ISO-8601 with just the Date part, no time: needed for error messages
|
protected static String |
DATE_FORMAT_STR_RFC1123
This constant defines the date format specified by
RFC 1123 / RFC 822.
|
protected static Locale |
DEFAULT_LOCALE |
protected static TimeZone |
DEFAULT_TIMEZONE
By default we use UTC for everything, with Jackson 2.7 and later
(2.6 and earlier relied on GMT)
|
static StdDateFormat |
instance
A singleton instance can be used for cloning purposes, as a blueprint of sorts.
|
protected static Pattern |
PATTERN_ISO8601 |
protected static Pattern |
PATTERN_PLAIN |
protected static String |
PATTERN_PLAIN_STR |
AM_PM_FIELD, calendar, 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, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD| Modifier | Constructor and Description |
|---|---|
|
StdDateFormat() |
|
StdDateFormat(TimeZone tz,
Locale loc)
Deprecated.
|
protected |
StdDateFormat(TimeZone tz,
Locale loc,
Boolean lenient) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_clearFormats() |
protected static <T> boolean |
_equals(T value1,
T value2) |
protected static void |
_format(TimeZone tz,
Locale loc,
Date date,
StringBuffer buffer) |
protected Date |
_parseAsISO8601(String dateStr,
ParsePosition pos) |
protected Date |
_parseDate(String dateStr,
ParsePosition pos) |
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 |
isLenient() |
protected boolean |
looksLikeISO8601(String dateStr)
Helper method used to figure out if input looks like valid
ISO-8601 string.
|
Date |
parse(String dateStr) |
Date |
parse(String dateStr,
ParsePosition pos) |
protected Date |
parseAsISO8601(String dateStr,
ParsePosition pos) |
protected Date |
parseAsRFC1123(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 |
withLenient(Boolean b) |
StdDateFormat |
withLocale(Locale loc) |
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, parseObjectprotected static final String PATTERN_PLAIN_STR
protected static final Pattern PATTERN_PLAIN
protected static final Pattern PATTERN_ISO8601
public static final String DATE_FORMAT_STR_ISO8601
protected static final String DATE_FORMAT_STR_PLAIN
protected static final String DATE_FORMAT_STR_RFC1123
protected static final String[] ALL_FORMATS
protected static final TimeZone DEFAULT_TIMEZONE
protected static final Locale DEFAULT_LOCALE
protected static final DateFormat DATE_FORMAT_RFC1123
protected static final DateFormat DATE_FORMAT_ISO8601
public static final StdDateFormat instance
protected transient TimeZone _timezone
protected final Locale _locale
protected Boolean _lenient
Cannot be `final` because setLenient(boolean) returns
`void`.
public StdDateFormat()
@Deprecated public StdDateFormat(TimeZone tz, Locale loc)
public static TimeZone getDefaultTimeZone()
public StdDateFormat withTimeZone(TimeZone tz)
public StdDateFormat withLocale(Locale loc)
public StdDateFormat withLenient(Boolean b)
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 Date parse(String dateStr) throws ParseException
parse in class DateFormatParseExceptionpublic Date parse(String dateStr, ParsePosition pos)
parse in class DateFormatprotected Date _parseDate(String dateStr, ParsePosition pos) throws ParseException
ParseExceptionpublic StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
format in class DateFormatprotected static void _format(TimeZone tz, Locale loc, Date date, StringBuffer buffer)
public String toPattern()
public boolean equals(Object o)
equals in class DateFormatpublic int hashCode()
hashCode in class DateFormatprotected boolean looksLikeISO8601(String dateStr)
protected Date parseAsISO8601(String dateStr, ParsePosition pos) throws ParseException
ParseExceptionprotected Date _parseAsISO8601(String dateStr, ParsePosition pos) throws IllegalArgumentException, ParseException
protected Date parseAsRFC1123(String dateStr, ParsePosition pos)
protected void _clearFormats()
protected static <T> boolean _equals(T value1,
T value2)
Copyright © 2008–2017 FasterXML. All rights reserved.