public class ZonedDateTimeSerializer extends InstantSerializerBase<ZonedDateTime>
JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
protected DateTimeFormatter |
_formatter
Specific format to use, if not default format: non null value
also indicates that serialization is to be done as JSON String,
not numeric timestamp, unless
_useTimestamp is true. |
protected JsonFormat.Shape |
_shape |
protected Boolean |
_useNanoseconds
Flag that indicates that numeric timestamp values must be written using
nanosecond timestamps if the datatype supports such resolution,
regardless of other settings.
|
protected Boolean |
_useTimestamp
Flag that indicates that serialization must be done as the
Java timestamp, regardless of other settings.
|
protected Boolean |
_writeZoneId
Flag for
JsonFormat.Feature.WRITE_DATES_WITH_ZONE_ID |
static ZonedDateTimeSerializer |
INSTANCE |
_handledType
Modifier | Constructor and Description |
---|---|
protected |
ZonedDateTimeSerializer() |
|
ZonedDateTimeSerializer(DateTimeFormatter formatter) |
protected |
ZonedDateTimeSerializer(ZonedDateTimeSerializer base,
Boolean useTimestamp,
Boolean useNanoseconds,
DateTimeFormatter formatter,
Boolean writeZoneId) |
protected |
ZonedDateTimeSerializer(ZonedDateTimeSerializer base,
Boolean useTimestamp,
DateTimeFormatter formatter,
Boolean writeZoneId) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_useTimestampExplicitOnly(SerializerProvider provider) |
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
JsonSerializer<?> |
createContextual(SerializerProvider prov,
BeanProperty property)
Method called to see if a different (or differently configured) serializer
is needed to serialize values of specified property.
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
protected JsonToken |
serializationShape(SerializerProvider provider)
Overridable helper method used from
serializeWithType(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer) , to indicate
shape of value during serialization; needed to know how type id is to be
serialized. |
void |
serialize(ZonedDateTime value,
JsonGenerator g,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
void |
serializeWithType(T value,
JsonGenerator g,
SerializerProvider provider,
TypeSerializer typeSer)
Method that can be called to ask implementation to serialize
values of type this serializer handles, using specified type serializer
for embedding necessary type information.
|
boolean |
shouldWriteWithZoneId(SerializerProvider ctxt) |
protected boolean |
useNanoseconds(SerializerProvider provider) |
protected boolean |
useTimestamp(SerializerProvider provider) |
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> |
withFeatures(Boolean writeZoneId)
Deprecated.
|
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> |
withFeatures(Boolean writeZoneId,
Boolean writeNanoseconds) |
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> |
withFormat(Boolean useTimestamp,
DateTimeFormatter formatter,
JsonFormat.Shape shape) |
_acceptTimestampVisitor
_neitherNull, _nonEmpty, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId
public static final ZonedDateTimeSerializer INSTANCE
protected final Boolean _writeZoneId
JsonFormat.Feature.WRITE_DATES_WITH_ZONE_ID
protected final Boolean _useTimestamp
protected final Boolean _useNanoseconds
protected final DateTimeFormatter _formatter
_useTimestamp
is true.protected final JsonFormat.Shape _shape
protected ZonedDateTimeSerializer()
public ZonedDateTimeSerializer(DateTimeFormatter formatter)
protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base, Boolean useTimestamp, DateTimeFormatter formatter, Boolean writeZoneId)
protected ZonedDateTimeSerializer(ZonedDateTimeSerializer base, Boolean useTimestamp, Boolean useNanoseconds, DateTimeFormatter formatter, Boolean writeZoneId)
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> withFormat(Boolean useTimestamp, DateTimeFormatter formatter, JsonFormat.Shape shape)
withFormat
in class InstantSerializerBase<ZonedDateTime>
@Deprecated protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> withFeatures(Boolean writeZoneId)
protected com.fasterxml.jackson.datatype.jsr310.ser.JSR310FormattedSerializerBase<?> withFeatures(Boolean writeZoneId, Boolean writeNanoseconds)
public void serialize(ZonedDateTime value, JsonGenerator g, SerializerProvider provider) throws IOException
JsonSerializer
serialize
in class InstantSerializerBase<ZonedDateTime>
value
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.IOException
public boolean shouldWriteWithZoneId(SerializerProvider ctxt)
protected JsonToken serializationShape(SerializerProvider provider)
serializeWithType(T, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer)
, to indicate
shape of value during serialization; needed to know how type id is to be
serialized.serializationShape
in class InstantSerializerBase<ZonedDateTime>
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException
ContextualSerializer
createContextual
in interface ContextualSerializer
prov
- Serializer provider to use for accessing config, other serializersproperty
- Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller cannot provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is)JsonMappingException
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
StdSerializer
getSchema
in interface SchemaAware
getSchema
in class StdSerializer<T>
provider
- The serializer provider.typeHint
- A hint about the type.public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class StdSerializer<T>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
protected boolean useTimestamp(SerializerProvider provider)
protected boolean _useTimestampExplicitOnly(SerializerProvider provider)
protected boolean useNanoseconds(SerializerProvider provider)
public void serializeWithType(T value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException
JsonSerializer
Default implementation will throw UnsupportedOperationException
to indicate that proper type handling needs to be implemented.
For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like:
// note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen);and implementations for type serialized as JSON Arrays or Objects would differ slightly, as
START-ARRAY
/END-ARRAY
and
START-OBJECT
/END-OBJECT
pairs
need to be properly handled with respect to serializing of contents.serializeWithType
in class JsonSerializer<T>
value
- Value to serialize; can not be null.g
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.typeSer
- Type serializer to use for including type informationIOException
Copyright © 2019 JBoss by Red Hat. All rights reserved.