Top Description Fields Constructors Methods
tools.jackson.databind.cfg

public final Enum DateTimeFeature

extends Enum<DateTimeFeature>
implements DatatypeFeature
Class Inheritance
All Implemented Interfaces
tools.jackson.databind.cfg.DatatypeFeature, tools.jackson.core.util.JacksonFeature
Imports
tools.jackson.databind.DeserializationContext

Configurable on/off features to configure Date/Time handling. Mostly used to configure Java 8 Time (java.time) type handling (see tools.jackson.databind.ext.javatime.JavaTimeInitializer) but also to "legacy" (java.util.Date, java.util.Calendar) and Joda Date/Time.

Field Summary

Modifier and TypeField and Description
private final boolean
_enabledByDefault

Whether feature is enabled or disabled by default.

private final int
public static final DateTimeFeature
ADJUST_DATES_TO_CONTEXT_TIME_ZONE

Feature that specifies whether context provided java.util.TimeZone (DeserializationContext#getTimeZone() should be used to adjust Date/Time values on deserialization, even if value itself contains timezone information.

public static final DateTimeFeature
ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS

Feature that controls whether stringified numbers (Strings that without quotes would be legal JSON Numbers) may be interpreted as timestamps (enabled) or not (disabled), in case where there is an explicitly defined pattern (DateTimeFormatter, usually by using @JsonFormat annotation) for value.

private static final int
public static final DateTimeFeature
NORMALIZE_DESERIALIZED_ZONE_ID

Feature that determines whether java.time.ZoneId is normalized (via call to java.time.ZoneId#normalized()) when deserializing types like java.time.ZonedDateTime.

public static final DateTimeFeature
ONE_BASED_MONTHS

Feature that determines whether java.time.Month is serialized as and deserialized expected a zero- (false) or one-based index (true).

public static final DateTimeFeature
READ_DATE_TIMESTAMPS_AS_NANOSECONDS

Feature that controls whether numeric timestamp values are expected to be written using nanosecond timestamps (enabled) or not (disabled), if and only if datatype supports such resolution.

public static final DateTimeFeature
USE_TIME_ZONE_FOR_LENIENT_DATE_PARSING

Feature that determines whether the java.util.TimeZone of the tools.jackson.databind.DeserializationContext is used when leniently deserializing java.time.LocalDate or java.time.LocalDateTime from the UTC/ISO instant format.

public static final DateTimeFeature
WRITE_DATE_KEYS_AS_TIMESTAMPS

Feature that determines whether java.util.Dates (and sub-types) used as java.util.Map keys are serialized as time stamps or not (if not, will be serialized as textual values).

public static final DateTimeFeature
WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS

Feature that controls whether numeric timestamp values are to be written using nanosecond timestamps (enabled) or not (disabled); if and only if datatype supports such resolution.

public static final DateTimeFeature
WRITE_DATES_AS_TIMESTAMPS

Feature that determines whether Date (and date/time) values (and Date-based things like java.util.Calendars) are to be serialized as numeric time stamps (true; the default), or as something else (usually textual representation).

public static final DateTimeFeature
WRITE_DATES_WITH_CONTEXT_TIME_ZONE

Feature that determines whether timezone/offset included in zoned date/time values (note: does NOT java.util.Date will be overridden if there is an explicitly set context time zone.

public static final DateTimeFeature
WRITE_DATES_WITH_ZONE_ID

Feature that determines whether date/date-time values should be serialized so that they include timezone id, in cases where type itself contains timezone information.

public static final DateTimeFeature
WRITE_DURATIONS_AS_TIMESTAMPS

Feature that determines whether time values that represents time periods (durations, periods, ranges) are to be serialized by default using a numeric (true) or textual (false) representations.

Constructor Summary

AccessConstructor and Description
private
DateTimeFeature(boolean enabledByDefault)

Method Summary

Modifier and TypeMethod and Description
public boolean
enabledByDefault()

Implements tools.jackson.core.util.JacksonFeature.enabledByDefault.

Accessor for checking whether this feature is enabled by default.

public boolean
enabledIn(int flags)

Implements tools.jackson.core.util.JacksonFeature.enabledIn.

Convenience method for checking whether feature is enabled in given bitmask.

public int
featureIndex()

Implements tools.jackson.databind.cfg.DatatypeFeature.featureIndex.

Internal index used for efficient storage and index; no user serviceable contents inside!

public int
getMask()

Implements tools.jackson.core.util.JacksonFeature.getMask.

Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.

public static DateTimeFeature
public static DateTimeFeature[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

_enabledByDefaultback to summary
private final boolean _enabledByDefault

Whether feature is enabled or disabled by default.

_maskback to summary
private final int _mask
ADJUST_DATES_TO_CONTEXT_TIME_ZONEback to summary
public static final DateTimeFeature ADJUST_DATES_TO_CONTEXT_TIME_ZONE

Feature that specifies whether context provided java.util.TimeZone (DeserializationContext#getTimeZone() should be used to adjust Date/Time values on deserialization, even if value itself contains timezone information. If enabled, contextual TimeZone will essentially override any other TimeZone information; if disabled, it will only be used if value itself does not contain any TimeZone information.

Note that exact behavior depends on date/time types in question; and specifically JDK type of java.util.Date does NOT have in-built timezone information so this setting has no effect. Further, while java.util.Calendar does have this information basic JDK java.text.SimpleDateFormat is unable to retain parsed zone information, and as a result, java.util.Calendar will always get context timezone adjustment regardless of this setting.

Taking above into account, this feature is supported only by extension modules for Joda and Java 8 date/time datatypes.

Feature used to be one of tools.jackson.databind.DeserializationFeatures in Jackson 2.x but was moved here in 3.0.

ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPSback to summary
public static final DateTimeFeature ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS

Feature that controls whether stringified numbers (Strings that without quotes would be legal JSON Numbers) may be interpreted as timestamps (enabled) or not (disabled), in case where there is an explicitly defined pattern (DateTimeFormatter, usually by using @JsonFormat annotation) for value.

Note that when the default pattern is used (no custom pattern defined), stringified numbers are always accepted as timestamps regardless of this feature.

FEATURE_INDEXback to summary
private static final int FEATURE_INDEX
NORMALIZE_DESERIALIZED_ZONE_IDback to summary
public static final DateTimeFeature NORMALIZE_DESERIALIZED_ZONE_ID

Feature that determines whether java.time.ZoneId is normalized (via call to java.time.ZoneId#normalized()) when deserializing types like java.time.ZonedDateTime.

Default setting is enabled, for backwards-compatibility with Jackson 2.15.

ONE_BASED_MONTHSback to summary
public static final DateTimeFeature ONE_BASED_MONTHS

Feature that determines whether java.time.Month is serialized as and deserialized expected a zero- (false) or one-based index (true). For example, Month.JANUARY would be serialized as 1 when enabled but as 0 when disabled. Conversely JSON Number 1 would be deserialized as Month.JANUARY when enabled, but as Month.FEBRUARY when disabled.

Default setting is true, meaning that Month is serialized using one-based index and deserialized expecting one-based index.

Note

default setting changed between Jackson 2.x (was false) and Jackson 3.0 (changed to true).

READ_DATE_TIMESTAMPS_AS_NANOSECONDSback to summary
public static final DateTimeFeature READ_DATE_TIMESTAMPS_AS_NANOSECONDS

Feature that controls whether numeric timestamp values are expected to be written using nanosecond timestamps (enabled) or not (disabled), if and only if datatype supports such resolution. Only newer datatypes (such as Java8 Date/Time) support such resolution -- older types (pre-Java8 java.util.Date etc) and Joda do not -- and this setting has no effect on such types.

If disabled, standard millisecond timestamps are assumed. This is the counterpart to DateTimeFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS.

Feature used to be one of tools.jackson.databind.DeserializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is enabled by default, to support most accurate time values possible (where available).

USE_TIME_ZONE_FOR_LENIENT_DATE_PARSINGback to summary
public static final DateTimeFeature USE_TIME_ZONE_FOR_LENIENT_DATE_PARSING

Feature that determines whether the java.util.TimeZone of the tools.jackson.databind.DeserializationContext is used when leniently deserializing java.time.LocalDate or java.time.LocalDateTime from the UTC/ISO instant format.

Default setting is disabled, for backwards-compatibility with Jackson 2.18.

WRITE_DATE_KEYS_AS_TIMESTAMPSback to summary
public static final DateTimeFeature WRITE_DATE_KEYS_AS_TIMESTAMPS

Feature that determines whether java.util.Dates (and sub-types) used as java.util.Map keys are serialized as time stamps or not (if not, will be serialized as textual values).

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default, meaning that Date-valued Map keys are serialized as textual (ISO-8601) values.

WRITE_DATE_TIMESTAMPS_AS_NANOSECONDSback to summary
public static final DateTimeFeature WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS

Feature that controls whether numeric timestamp values are to be written using nanosecond timestamps (enabled) or not (disabled); if and only if datatype supports such resolution. Only newer datatypes (such as Java8 Date/Time) support such resolution -- older types (pre-Java8 java.util.Date etc) and Joda do not -- and this setting has no effect on such types.

If disabled, standard millisecond timestamps are assumed. This is the counterpart to DateTimeFeature#READ_DATE_TIMESTAMPS_AS_NANOSECONDS.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is enabled by default, to support most accurate time values possible.

WRITE_DATES_AS_TIMESTAMPSback to summary
public static final DateTimeFeature WRITE_DATES_AS_TIMESTAMPS

Feature that determines whether Date (and date/time) values (and Date-based things like java.util.Calendars) are to be serialized as numeric time stamps (true; the default), or as something else (usually textual representation). If textual representation is used, the actual format depends on configuration settings including possible per-property use of @JsonFormat annotation, globally configured java.text.DateFormat.

For "classic" JDK date types (java.util.Date, java.util.Calendar) the default formatting is provided by tools.jackson.databind.util.StdDateFormat, and corresponds to format String of "yyyy-MM-dd'T'HH:mm:ss.SSSX" (see java.text.DateFormat for details of format Strings). Whether this feature affects handling of other date-related types depend on handlers of those types, although ideally they should use this feature

Note

whether java.util.Map keys are serialized as Strings or not is controlled using WRITE_DATE_KEYS_AS_TIMESTAMPS instead of this feature.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default as of Jackson 3.0 (in 2.x it was enabled), so that date/time are by default serialized as textual values NOT timestamps.

WRITE_DATES_WITH_CONTEXT_TIME_ZONEback to summary
public static final DateTimeFeature WRITE_DATES_WITH_CONTEXT_TIME_ZONE

Feature that determines whether timezone/offset included in zoned date/time values (note: does NOT java.util.Date will be overridden if there is an explicitly set context time zone. If disabled, timezone/offset value is used-is; if enabled, context time zone is used instead.

Note that this setting only affects "Zoned" date/time values of Java 8 date/time types -- it will have no effect on old java.util value handling (of which java.util.Date has no timezone information and must use contextual timezone, implicit or explicit; and java.util.Calendar which will always use timezone Calendar value has). Setting is also ignored by Joda date/time values.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is enabled by default for backwards-compatibility purposes (from Jackson 2.x)

WRITE_DATES_WITH_ZONE_IDback to summary
public static final DateTimeFeature WRITE_DATES_WITH_ZONE_ID

Feature that determines whether date/date-time values should be serialized so that they include timezone id, in cases where type itself contains timezone information. Including this information may lead to compatibility issues because ISO-8601 specification does not define formats that include such information.

If enabled, Timezone id should be included using format specified with Java 8 DateTimeFormatter#ISO_ZONED_DATE_TIME definition (for example, '2011-12-03T10:15:30+01:00[Europe/Paris]').

Note

setting has no relevance if date/time values are serialized as timestamps.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default, so that zone id is NOT included; rather, timezone offset is used for ISO-8601 compatibility (if any timezone information is included in value).

WRITE_DURATIONS_AS_TIMESTAMPSback to summary
public static final DateTimeFeature WRITE_DURATIONS_AS_TIMESTAMPS

Feature that determines whether time values that represents time periods (durations, periods, ranges) are to be serialized by default using a numeric (true) or textual (false) representations. Note that numeric representation may mean either simple number, or an array of numbers, depending on type.

Feature used to be one of tools.jackson.databind.SerializationFeatures in Jackson 2.x but was moved here in 3.0.

Feature is disabled by default as of Jackson 3.0 (in 2.x it was enabled), so that period/duration are by default serialized as textual values, NOT timestamps.

Constructor Detail

DateTimeFeatureback to summary
private DateTimeFeature(boolean enabledByDefault)

Method Detail

enabledByDefaultback to summary
public boolean enabledByDefault()

Implements tools.jackson.core.util.JacksonFeature.enabledByDefault.

Doc from tools.jackson.core.util.JacksonFeature.enabledByDefault.

Accessor for checking whether this feature is enabled by default.

Annotations
@Override
enabledInback to summary
public boolean enabledIn(int flags)

Implements tools.jackson.core.util.JacksonFeature.enabledIn.

Doc from tools.jackson.core.util.JacksonFeature.enabledIn.

Convenience method for checking whether feature is enabled in given bitmask.

Annotations
@Override
featureIndexback to summary
public int featureIndex()

Implements tools.jackson.databind.cfg.DatatypeFeature.featureIndex.

Doc from tools.jackson.databind.cfg.DatatypeFeature.featureIndex.

Internal index used for efficient storage and index; no user serviceable contents inside!

Annotations
@Override
getMaskback to summary
public int getMask()

Implements tools.jackson.core.util.JacksonFeature.getMask.

Doc from tools.jackson.core.util.JacksonFeature.getMask.

Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.

Annotations
@Override
valueOfback to summary
public static DateTimeFeature valueOf(String name)
valuesback to summary
public static DateTimeFeature[] values()