Class LocalDateAdapter
java.lang.Object
net.thauvin.erik.frankfurter.internal.LocalDateAdapter
- All Implemented Interfaces:
JsonDeserializer<LocalDate>,JsonSerializer<LocalDate>
public final class LocalDateAdapter
extends Object
implements JsonDeserializer<LocalDate>, JsonSerializer<LocalDate>
Gson adapter for serializing and deserializing
LocalDate values.
This adapter reads and writes ISO‑8601 date strings such as
"2026-04-08". It is used internally by the Frankfurter client to
ensure consistent date handling across all JSON payloads.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(JsonElement json, Type type, JsonDeserializationContext ctx) Deserializes an ISO‑8601 date string into aLocalDate.serialize(LocalDate date, Type type, JsonSerializationContext ctx) Serializes aLocalDateinto its ISO‑8601 string representation.
-
Constructor Details
-
LocalDateAdapter
public LocalDateAdapter()
-
-
Method Details
-
deserialize
Deserializes an ISO‑8601 date string into aLocalDate.- Specified by:
deserializein interfaceJsonDeserializer<LocalDate>- Parameters:
json- the JSON element containing the date stringtype- the target type (ignored)ctx- the deserialization context (ignored)- Returns:
- the parsed
LocalDate
-
serialize
Serializes aLocalDateinto its ISO‑8601 string representation.- Specified by:
serializein interfaceJsonSerializer<LocalDate>- Parameters:
date- the date to serializetype- the target type (ignored)ctx- the serialization context (ignored)- Returns:
- a JSON string containing the ISO‑8601 representation of the date
-