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

public final Class JavaTimeInitializer

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.time.*, tools.jackson.databind.*, tools.jackson.databind.cfg.DateTimeFeature, tools.jackson.databind.deser.ValueInstantiator, .ValueInstantiators, tools.jackson.databind.deser.std.StdValueInstantiator, tools.jackson.databind.ext.javatime.deser.*, tools.jackson.databind.ext.javatime.deser.key.*, tools.jackson.databind.ext.javatime.ser.*, tools.jackson.databind.ext.javatime.ser.key.ZonedDateTimeKeySerializer, tools.jackson.databind.introspect.AnnotatedClass, .AnnotatedClassResolver, .AnnotatedMethod, tools.jackson.databind.module.SimpleDeserializers, .SimpleKeyDeserializers, .SimpleSerializers, tools.jackson.databind.ser.std.ToStringSerializer

Class that registers capability of deserializing and serializing (reading and writing) java.time values with the Jackson core.

In Jackson 3, the module is embedded in databind and handlers are automatically registered: approach is similar to one used by full JacksonModules.

Most java.time types are serialized as numbers (integers or decimals as appropriate) if the DateTimeFeature#WRITE_DATES_AS_TIMESTAMPS feature is enabled (or, for Duration, DateTimeFeature#WRITE_DURATIONS_AS_TIMESTAMPS), and otherwise are serialized in standard ISO-8601 string representation. ISO-8601 specifies formats for representing offset dates and times, zoned dates and times, local dates and times, periods, durations, zones, and more. All java.time types have built-in translation to and from ISO-8601 formats.

Granularity of timestamps is controlled through the companion features DateTimeFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS and DateTimeFeature#READ_DATE_TIMESTAMPS_AS_NANOSECONDS. For serialization, timestamps are written as fractional numbers (decimals), where the number is seconds and the decimal is fractional seconds, if WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS is enabled (it is by default), with resolution as fine as nanoseconds depending on the underlying JDK implementation. If WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS is disabled, timestamps are written as a whole number of milliseconds. At deserialization time, decimal numbers are always read as fractional second timestamps with up-to-nanosecond resolution, since the meaning of the decimal is unambiguous. The more ambiguous integer types are read as fractional seconds without a decimal point if READ_DATE_TIMESTAMPS_AS_NANOSECONDS is enabled (it is by default), and otherwise they are read as milliseconds.

Some exceptions to this standard serialization/deserialization rule:

Field Summary

Modifier and TypeField and Description
private static final JavaTimeInitializer
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private AnnotatedMethod
_findFactory(AnnotatedClass cls, String name, Class<?>... argTypes)

public static JavaTimeInitializer
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static final JavaTimeInitializer INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

JavaTimeInitializerback to summary
private JavaTimeInitializer()

Method Detail

_findFactoryback to summary
private AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class<?>... argTypes)
getInstanceback to summary
public static JavaTimeInitializer getInstance()
setupModuleback to summary
public void setupModule(JacksonModule.SetupContext context)