LocalDateSerializationAdapter<G extends Generator, P extends Parser, DC extends DeserializationContext<Parser>, SC extends SerializationContext<Generator>> class final

Serializes and deserializes Dart LocalDate values to and from ISO-8601 strings.

The LocalDateSerializationAdapter provides a unified adapter for handling LocalDate objects in both serialization and deserialization processes, including JSON and generic generators/parsers.

Serialization Rules

  • Converts the LocalDate to an ISO-8601 string (e.g., "2025-10-28") using toString().
  • Writes the value using generator.writeString().

Deserialization Rules

  • Accepts ISO-8601 formatted strings and converts them to LocalDate.
  • Uses the context's ConversionService if available for type conversion.
  • Throws InvalidFormatException if the input is not a valid ISO-8601 date string.

Example

final adapter = LocalDateSerializationAdapter();

final date = LocalDate(2025, 10, 28);
adapter.serialize(date, generator, context);
// JSON output: "2025-10-28"

final parsed = adapter.deserialize(parser, context, Class.forType(LocalDate));
// parsed is a LocalDate instance

Notes

  • This adapter only handles the date portion; time is ignored.
  • For non-ISO formats, use a custom JsonConverter.
Implemented types
Annotations
  • @Generic.new(LocalDateSerializationAdapter)

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

canDeserialize(Class type) → bool
Returns whether the given type can be deserialized by the system.
override
canSerialize(Class type) → bool
Returns whether the given type can be serialized by the system.
override
deserialize(P parser, DC ctxt, Class toClass) → LocalDate?
Deserializes an object of type T using the given P and DeserializationContext.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serialize(LocalDate value, G generator, SC serializer) → void
Serializes an object of type T into an object using the provided Generator and SerializationContext.
override
supports(DeserializationContext<Parser> context) → bool
Determines whether this deserializer supports the given deserialization context.
inherited
supportsContext(SerializationContext<Generator> context) → bool
Determines whether this serializer supports the given serialization context.
inherited
toClass() → Class<LocalDate>
Provides a contract for types capable of exposing their associated runtime Class metadata representation within the Jetleaf reflection system.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited