Class V9DateTimeJsonAdapter
- java.lang.Object
-
- com.prowidesoftware.swift.model.mx.adapters.v9.V9DateTimeJsonAdapter
-
- All Implemented Interfaces:
com.google.gson.JsonDeserializer<java.time.OffsetDateTime>,com.google.gson.JsonSerializer<java.time.OffsetDateTime>
public class V9DateTimeJsonAdapter extends java.lang.Object implements com.google.gson.JsonSerializer<java.time.OffsetDateTime>, com.google.gson.JsonDeserializer<java.time.OffsetDateTime>Adapter for serializing and deserializingOffsetDateTimeto and from JSON in a format compatible with the legacyXMLGregorianCalendarused in older versions of the library.This adapter is used to maintain backward compatibility with systems that expect the older date-time format while allowing migration to Java 11's
OffsetDateTime.Serialization
Theserializemethod converts anOffsetDateTimeobject into a JSON structure similar to the structure used byXMLGregorianCalendar, preserving the fields for year, month, day, time, timezone, and fractional seconds if present.Deserialization
Thedeserializemethod converts a JSON structure formatted forXMLGregorianCalendarinto anOffsetDateTimeobject, parsing the legacy fields and converting them to their modern equivalents, including handling timezone and fractional seconds.- Since:
- 10.1.8
-
-
Constructor Summary
Constructors Constructor Description V9DateTimeJsonAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.OffsetDateTimedeserialize(com.google.gson.JsonElement xMLGregorianCalendarJsonElement, java.lang.reflect.Type type, com.google.gson.JsonDeserializationContext jsonDeserializationContext)Deserializes a JSON element into anOffsetDateTime, converting the legacyXMLGregorianCalendarfields into their modern equivalents.com.google.gson.JsonElementserialize(java.time.OffsetDateTime offsetDateTime, java.lang.reflect.Type type, com.google.gson.JsonSerializationContext jsonSerializationContext)Serializes anOffsetDateTimeinto JSON format compatible with the olderXMLGregorianCalendarrepresentation.
-
-
-
Method Detail
-
serialize
public com.google.gson.JsonElement serialize(java.time.OffsetDateTime offsetDateTime, java.lang.reflect.Type type, com.google.gson.JsonSerializationContext jsonSerializationContext)Serializes anOffsetDateTimeinto JSON format compatible with the olderXMLGregorianCalendarrepresentation.- Specified by:
serializein interfacecom.google.gson.JsonSerializer<java.time.OffsetDateTime>- Parameters:
offsetDateTime- theOffsetDateTimeto be serializedtype- the specific genericized type of the source objectjsonSerializationContext- the context for serialization- Returns:
- a
JsonElementrepresenting the serialized date-time information
-
deserialize
public java.time.OffsetDateTime deserialize(com.google.gson.JsonElement xMLGregorianCalendarJsonElement, java.lang.reflect.Type type, com.google.gson.JsonDeserializationContext jsonDeserializationContext)Deserializes a JSON element into anOffsetDateTime, converting the legacyXMLGregorianCalendarfields into their modern equivalents.- Specified by:
deserializein interfacecom.google.gson.JsonDeserializer<java.time.OffsetDateTime>- Parameters:
xMLGregorianCalendarJsonElement- the JSON data to be deserializedtype- the specific genericized type of the source objectjsonDeserializationContext- the context for deserialization- Returns:
- the deserialized
OffsetDateTime, ornullif parsing fails
-
-