Formatted Local Time Serializer
An abstract serializer for LocalTime values that uses a custom DateTimeFormat to serialize and deserialize the value.
name is the name of the serializer. The SerialDescriptor.serialName of the resulting serializer is kotlinx.datetime.LocalTime/serializer/
name. SerialDescriptor.serialName must be unique across all serializers in the same serialization context. When defining a serializer in a library, it is recommended to use the fully qualified class name in name to avoid conflicts with serializers defined by other libraries and client code.
This serializer is abstract and must be subclassed to provide a concrete serializer. Example:
// serializes LocalTime(12, 30) as "12:30:00.000"
object FixedWidthTimeSerializer : FormattedLocalTimeSerializer("my.package.FixedWidthTime", LocalTime.Format {
hour(); char(':'); minute(); char(':'); second(); char('.'); secondFraction(3)
})
Note that LocalTime is kotlinx.serialization.Serializable by default, so it is not necessary to create custom serializers when the format is not important. Additionally, LocalTimeIso8601Serializer is provided for the ISO 8601 format.