Top Description Inners Fields Constructors Methods
tools.jackson.databind.ext.javatime.deser

public Class InstantDeserializer<T extends Temporal>

extends JSR310DateTimeDeserializerBase<T extends Temporal>
Class Inheritance
Imports
java.math.BigDecimal, java.time.*, java.time.format.DateTimeFormatter, java.time.temporal.Temporal, .TemporalAccessor, java.util.Objects, java.util.function.BiFunction, .Function, java.util.regex.Matcher, .Pattern, com.fasterxml.jackson.annotation.JsonFormat, tools.jackson.core.*, tools.jackson.core.io.NumberInput, tools.jackson.databind.BeanProperty, .DeserializationContext, tools.jackson.databind.cfg.DateTimeFeature, tools.jackson.databind.ext.javatime.util.DecimalUtils

Deserializer for Java 8 temporal Instants, OffsetDateTime, and ZonedDateTimes.
Author
Nick Williams

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
protected final Boolean
_adjustToContextTZOverride

Flag for JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE

protected final Boolean
_readTimestampsAsNanosOverride

Flag for JsonFormat.Feature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS

protected final BiFunction<T, ZoneId, T>
private static final boolean
private static final boolean
protected final Function<InstantDeserializer.FromIntegerArguments, T>
protected final Function<InstantDeserializer.FromDecimalArguments, T>
public static final InstantDeserializer<Instant>
protected static final Pattern
ISO8601_COLONLESS_OFFSET_REGEX

Constants used to check if ISO 8601 time string is colon-less.

public static final InstantDeserializer<OffsetDateTime>
protected final Function<TemporalAccessor, T>
protected final boolean
replaceZeroOffsetAsZ

In case of vanilla `Instant` we seem to need to translate "+0000 | +00:00 | +00" timezone designator into plain "Z" for some reason; see [jackson-modules-java8#18] for more info

public static final InstantDeserializer<ZonedDateTime>
Inherited from tools.jackson.databind.ext.javatime.deser.JSR310DateTimeDeserializerBase:
_formatter_shape

Constructor Summary

AccessConstructor and Description
protected
InstantDeserializer(Class<T> supportedType, DateTimeFormatter formatter, Function<TemporalAccessor, T> parsedToValue, Function<InstantDeserializer.FromIntegerArguments, T> fromMilliseconds, Function<InstantDeserializer.FromDecimalArguments, T> fromNanoseconds, BiFunction<T, ZoneId, T> adjust, boolean replaceZeroOffsetAsZ, boolean normalizeZoneId, boolean readNumericStringsAsTimestamp)

protected
protected
InstantDeserializer(InstantDeserializer<T> base, Boolean adjustToContextTimezoneOverride)

protected
protected
InstantDeserializer(InstantDeserializer<T> base, Boolean leniency, DateTimeFormatter formatter, JsonFormat.Shape shape, Boolean adjustToContextTimezoneOverride, Boolean readTimestampsAsNanosOverride)

Method Summary

Modifier and TypeMethod and Description
protected int
protected T
protected T
_fromLong(DeserializationContext context, long timestamp)

protected T
protected JSR310DateTimeDeserializerBase<?>
private static String
private static OffsetDateTime
public T
deserialize(JsonParser p, DeserializationContext ctxt)

Implements abstract tools.jackson.databind.ValueDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles.

private ZoneId
private static String
private String
protected boolean
protected boolean
protected InstantDeserializer<T>
protected InstantDeserializer<T>
Inherited from tools.jackson.databind.ext.javatime.deser.JSR310DateTimeDeserializerBase:
_throwNoNumericTimestampNeedTimeZonecreateContextualwithShape

Field Detail

_adjustToContextTZOverrideback to summary
protected final Boolean _adjustToContextTZOverride

Flag for JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE

_readTimestampsAsNanosOverrideback to summary
protected final Boolean _readTimestampsAsNanosOverride

Flag for JsonFormat.Feature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS

adjustback to summary
protected final BiFunction<T, ZoneId, T> adjust
DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPSback to summary
private static final boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
DEFAULT_NORMALIZE_ZONE_IDback to summary
private static final boolean DEFAULT_NORMALIZE_ZONE_ID
fromMillisecondsback to summary
protected final Function<InstantDeserializer.FromIntegerArguments, T> fromMilliseconds
fromNanosecondsback to summary
protected final Function<InstantDeserializer.FromDecimalArguments, T> fromNanoseconds
INSTANTback to summary
public static final InstantDeserializer<Instant> INSTANT
ISO8601_COLONLESS_OFFSET_REGEXback to summary
protected static final Pattern ISO8601_COLONLESS_OFFSET_REGEX

Constants used to check if ISO 8601 time string is colon-less. See [jackson-modules-java8#131]

OFFSET_DATE_TIMEback to summary
public static final InstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME
parsedToValueback to summary
protected final Function<TemporalAccessor, T> parsedToValue
replaceZeroOffsetAsZback to summary
protected final boolean replaceZeroOffsetAsZ

In case of vanilla `Instant` we seem to need to translate "+0000 | +00:00 | +00" timezone designator into plain "Z" for some reason; see [jackson-modules-java8#18] for more info

ZONED_DATE_TIMEback to summary
public static final InstantDeserializer<ZonedDateTime> ZONED_DATE_TIME

Constructor Detail

InstantDeserializerback to summary
protected InstantDeserializer(Class<T> supportedType, DateTimeFormatter formatter, Function<TemporalAccessor, T> parsedToValue, Function<InstantDeserializer.FromIntegerArguments, T> fromMilliseconds, Function<InstantDeserializer.FromDecimalArguments, T> fromNanoseconds, BiFunction<T, ZoneId, T> adjust, boolean replaceZeroOffsetAsZ, boolean normalizeZoneId, boolean readNumericStringsAsTimestamp)
Since
2.16
InstantDeserializerback to summary
protected InstantDeserializer(InstantDeserializer<T> base, DateTimeFormatter f)
Annotations
@SuppressWarnings:unchecked
InstantDeserializerback to summary
protected InstantDeserializer(InstantDeserializer<T> base, Boolean adjustToContextTimezoneOverride)
Annotations
@SuppressWarnings:unchecked
InstantDeserializerback to summary
protected InstantDeserializer(InstantDeserializer<T> base, DateTimeFormatter f, Boolean leniency)
Annotations
@SuppressWarnings:unchecked
InstantDeserializerback to summary
protected InstantDeserializer(InstantDeserializer<T> base, Boolean leniency, DateTimeFormatter formatter, JsonFormat.Shape shape, Boolean adjustToContextTimezoneOverride, Boolean readTimestampsAsNanosOverride)

Method Detail

_countPeriodsback to summary
protected int _countPeriods(String str)
_fromDecimalback to summary
protected T _fromDecimal(DeserializationContext context, BigDecimal value)
_fromLongback to summary
protected T _fromLong(DeserializationContext context, long timestamp)
_fromStringback to summary
protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws JacksonException
_withFormatOverridesback to summary
protected JSR310DateTimeDeserializerBase<?> _withFormatOverrides(DeserializationContext ctxt, BeanProperty property, JsonFormat.Value formatOverrides)

Overrides tools.jackson.databind.ext.javatime.deser.JSR310DateTimeDeserializerBase._withFormatOverrides.

Annotations
@SuppressWarnings:unchecked
@Override
addInColonToOffsetIfMissingback to summary
private static String addInColonToOffsetIfMissing(String text)
decimalToOffsetDateTimeback to summary
private static OffsetDateTime decimalToOffsetDateTime(InstantDeserializer.FromDecimalArguments args)
deserializeback to summary
public T deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException

Implements abstract tools.jackson.databind.ValueDeserializer.deserialize.

Doc from tools.jackson.databind.ValueDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles. Returned instance is to be constructed by method itself.

Pre-condition for this method is that the parser points to the first event that is part of value to deserializer (and which is never JSON 'null' literal, more on this below): for simple types it may be the only value; and for structured types the Object start marker or a FIELD_NAME.

The two possible input conditions for structured types result from polymorphism via fields. In the ordinary case, Jackson calls this method when it has encountered an OBJECT_START, and the method implementation must advance to the next token to see the first field name. If the application configures polymorphism via a field, then the object looks like the following.

      {
          "@class": "class name",
          ...
      }
  
Jackson consumes the two tokens (the @class field name and its value) in order to learn the class and select the deserializer. Thus, the stream is pointing to the FIELD_NAME for the first field after the @class. Thus, if you want your method to work correctly both with and without polymorphism, you must begin your method with:
       if (p.currentToken() == JsonToken.START_OBJECT) {
         p.nextToken();
       }
  
This results in the stream pointing to the field name, so that the two conditions align.

Post-condition is that the parser will point to the last event that is part of deserialized value (or in case deserialization fails, event that was not recognized or usable, which may be the same event as the one it pointed to upon call).

Handling null values (JsonToken.VALUE_NULL)
: Note that this method is never called for the JSON null literal to avoid every deserializer from having to handle null values. Instead, the ValueDeserializer#getNullValue(DeserializationContext) method is called to produce a null value. To influence null handling, custom deserializers should override ValueDeserializer#getNullValue(DeserializationContext) and usually also ValueDeserializer#getNullAccessPattern().

Annotations
@SuppressWarnings:unchecked
@Override
getZoneback to summary
private ZoneId getZone(DeserializationContext context)
replaceZeroOffsetAsZback to summary
private static String replaceZeroOffsetAsZ(String text)
replaceZeroOffsetAsZIfNecessaryback to summary
private String replaceZeroOffsetAsZIfNecessary(String text)
shouldAdjustToContextTimezoneback to summary
protected boolean shouldAdjustToContextTimezone(DeserializationContext context)
shouldReadTimestampsAsNanosecondsback to summary
protected boolean shouldReadTimestampsAsNanoseconds(DeserializationContext context)
withDateFormatback to summary
protected InstantDeserializer<T> withDateFormat(DateTimeFormatter dtf)

Implements abstract tools.jackson.databind.ext.javatime.deser.JSR310DateTimeDeserializerBase.withDateFormat.

Annotations
@Override
withLeniencyback to summary
protected InstantDeserializer<T> withLeniency(Boolean leniency)

Implements abstract tools.jackson.databind.ext.javatime.deser.JSR310DateTimeDeserializerBase.withLeniency.

Annotations
@Override
tools.jackson.databind.ext.javatime.deser back to summary

public Class InstantDeserializer.FromDecimalArguments

extends Object
Class Inheritance
  • java.lang.Object
  • tools.jackson.databind.ext.javatime.deser.InstantDeserializer.FromDecimalArguments

Field Summary

Modifier and TypeField and Description
public final int
public final long
public final ZoneId

Constructor Summary

AccessConstructor and Description
pack-priv
FromDecimalArguments(long integer, int fraction, ZoneId zoneId)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fractionback to summary
public final int fraction
integerback to summary
public final long integer
zoneIdback to summary
public final ZoneId zoneId

Constructor Detail

FromDecimalArgumentsback to summary
pack-priv FromDecimalArguments(long integer, int fraction, ZoneId zoneId)
tools.jackson.databind.ext.javatime.deser back to summary

public Class InstantDeserializer.FromIntegerArguments

extends Object
Class Inheritance
  • java.lang.Object
  • tools.jackson.databind.ext.javatime.deser.InstantDeserializer.FromIntegerArguments

Field Summary

Modifier and TypeField and Description
public final long
public final ZoneId

Constructor Summary

AccessConstructor and Description
pack-priv
FromIntegerArguments(long value, ZoneId zoneId)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
public final long value
zoneIdback to summary
public final ZoneId zoneId

Constructor Detail

FromIntegerArgumentsback to summary
pack-priv FromIntegerArguments(long value, ZoneId zoneId)