java.lang.Object
java.text.Format
java.text.DateFormat
tools.jackson.databind.util.StdDateFormat
- All Implemented Interfaces:
Serializable,Cloneable
Jackson's internal
Note that `X` in format String refers to ISO-8601 timezone offset notation which produces values like "-08:00" -- that is, full minute/hour combo without colon, not using `Z` as alias for "+00:00".
DateFormat implementation used by standard Date
serializers and deserializers to implement default behavior: does NOT
fully implement all aspects expected by DateFormat and as a consequence
SHOULD NOT to be used by code outside core Jackson databind functionality.
In particular, ParsePosition argument of parse(String, ParsePosition)
and format(Date, StringBuffer, FieldPosition) methods is fully ignored;
Jackson itself never calls these methods.
For serialization defaults to using
an ISO-8601 compliant format (format String "yyyy-MM-dd'T'HH:mm:ss.SSSX")
and for deserialization, both ISO-8601 and RFC-1123.
Note that `X` in format String refers to ISO-8601 timezone offset notation which produces values like "-08:00" -- that is, full minute/hour combo without colon, not using `Z` as alias for "+00:00".
Note also that to enable use of colon in timezone offset is possible by using method
withColonInTimeZone(boolean) for creating new differently configured format instance.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BooleanExplicit override for leniency, if specified.protected final Localeprotected TimeZoneCaller may want to explicitly override timezone to use; if so, we will have non-null value here.protected booleanWhether the TZ offset must be formatted with a colon between hours and minutes (HH:mmformat)protected static final String[]For error messages we'll also need a list of all formats.protected static final CalendarBlueprint "Calendar" instance for use during formatting.protected static final DateFormatstatic final StringDefines a commonly used date format that conforms to ISO-8601 date formatting standard, when it includes basic undecorated timezone definition.protected static final StringISO-8601 with just the Date part, no time: needed for error messagesprotected static final StringThis constant defines the date format specified by RFC 1123 / RFC 822.protected static final Localeprotected static final TimeZoneBy default we use UTC for everythingstatic final StdDateFormatA singleton instance can be used for cloning purposes, as a blueprint of sorts.protected static final Patternprotected static final Patternprotected static final StringFields inherited from class java.text.DateFormat
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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStdDateFormat(TimeZone tz, Locale loc, Boolean lenient, boolean formatTzOffsetWithColon) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected static <T> boolean_equals(T value1, T value2) protected void_format(TimeZone tz, Locale loc, Date date, StringBuffer buffer) protected void_formatBCEYear(StringBuffer buffer, int bceYearNoSign) protected Calendar_getCalendar(TimeZone tz) protected Date_parseAsISO8601(String dateStr, ParsePosition bogus) protected Date_parseDate(String dateStr, ParsePosition pos) clone()booleanformat(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) static TimeZoneinthashCode()booleanAccessor 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.booleanprotected booleanlooksLikeISO8601(String dateStr) Helper method used to figure out if input looks like valid ISO-8601 string.parse(String dateStr, ParsePosition pos) protected DateparseAsISO8601(String dateStr, ParsePosition pos) protected DateparseAsRFC1123(String dateStr, ParsePosition pos) voidsetLenient(boolean enabled) Need to override since we need to keep track of leniency locally, and not via underlyingCalendarinstance like base class does.voidsetTimeZone(TimeZone tz) toString()withColonInTimeZone(boolean b) "Mutant factory" method that will return an instance that has specified handling of colon when serializing timezone (timezone either written like+0500or+05:00): eitherthisinstance (if setting would not change), or newly constructed instance with desired setting for colon inclusion."Mutant factory" method that will return an instance that has specified leniency setting: eitherthisinstance (if setting would not change), or newly constructed instance.withLocale(Locale loc) "Mutant factory" method that will return an instance that uses specifiedLocale: eitherthisinstance (if setting would not change), or newly constructed instance with differentLocaleto use.withTimeZone(TimeZone tz) Method used for creating a new instance with specified timezone; if no timezone specified, defaults to the default timezone (UTC).Methods inherited from class java.text.DateFormat
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, parseObject, setCalendar, setNumberFormatMethods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
-
Field Details
-
PATTERN_PLAIN_STR
- See Also:
-
PATTERN_PLAIN
-
PATTERN_ISO8601
-
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.- See Also:
-
DATE_FORMAT_STR_PLAIN
ISO-8601 with just the Date part, no time: needed for error messages- See Also:
-
DATE_FORMAT_STR_RFC1123
This constant defines the date format specified by RFC 1123 / RFC 822. Used for parsing via `SimpleDateFormat` as well as error messages.- See Also:
-
ALL_FORMATS
For error messages we'll also need a list of all formats. -
DEFAULT_TIMEZONE
By default we use UTC for everything -
DEFAULT_LOCALE
-
DATE_FORMAT_RFC1123
-
instance
A singleton instance can be used for cloning purposes, as a blueprint of sorts. -
CALENDAR
Blueprint "Calendar" instance for use during formatting. Cannot be used as is, due to thread-safety issues, but can be used for constructing actual instances more cheaply by cloning. -
_timezone
Caller may want to explicitly override timezone to use; if so, we will have non-null value here. -
_locale
-
_lenient
Explicit override for leniency, if specified.Cannot be `final` because
setLenient(boolean)returns `void`. -
_tzSerializedWithColon
protected boolean _tzSerializedWithColonWhether the TZ offset must be formatted with a colon between hours and minutes (HH:mmformat)NOTE: default changed to `true` in Jackson 3.0; was `false` earlier.
-
-
Constructor Details
-
StdDateFormat
public StdDateFormat() -
StdDateFormat
-
-
Method Details
-
getDefaultTimeZone
-
withTimeZone
Method used for creating a new instance with specified timezone; if no timezone specified, defaults to the default timezone (UTC). -
withLocale
"Mutant factory" method that will return an instance that uses specifiedLocale: eitherthisinstance (if setting would not change), or newly constructed instance with differentLocaleto use. -
withLenient
"Mutant factory" method that will return an instance that has specified leniency setting: eitherthisinstance (if setting would not change), or newly constructed instance. -
withColonInTimeZone
"Mutant factory" method that will return an instance that has specified handling of colon when serializing timezone (timezone either written like+0500or+05:00): eitherthisinstance (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.
-
clone
- Overrides:
clonein classDateFormat
-
getTimeZone
- Overrides:
getTimeZonein classDateFormat
-
setTimeZone
- Overrides:
setTimeZonein classDateFormat
-
setLenient
public void setLenient(boolean enabled) Need to override since we need to keep track of leniency locally, and not via underlyingCalendarinstance like base class does.- Overrides:
setLenientin classDateFormat
-
isLenient
public boolean isLenient()- Overrides:
isLenientin classDateFormat
-
isColonIncludedInTimeZone
public 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.NOTE: only relevant for serialization (formatting), as deserialization (parsing) always accepts optional colon but does not require it, regardless of this setting.
- Returns:
trueif a colon is to be inserted between the hours and minutes of the TZ offset when serializing as String; otherwisefalse
-
parse
- Overrides:
parsein classDateFormat- Throws:
ParseException
-
parse
- Specified by:
parsein classDateFormat
-
_parseDate
- Throws:
ParseException
-
format
- Specified by:
formatin classDateFormat
-
_format
-
_formatBCEYear
-
toString
-
toPattern
-
equals
- Overrides:
equalsin classDateFormat
-
hashCode
public int hashCode()- Overrides:
hashCodein classDateFormat
-
looksLikeISO8601
Helper method used to figure out if input looks like valid ISO-8601 string. -
parseAsISO8601
- Throws:
ParseException
-
_parseAsISO8601
protected Date _parseAsISO8601(String dateStr, ParsePosition bogus) throws IllegalArgumentException, ParseException -
parseAsRFC1123
-
_clearFormats
protected void _clearFormats() -
_getCalendar
-
_equals
protected static <T> boolean _equals(T value1, T value2)
-