| // This file was automatically generated from serializers.md by Knit tool. Do not edit. |
| package example.exampleSerializer14 |
| |
| import kotlinx.serialization.* |
| import kotlinx.serialization.json.* |
| import kotlinx.serialization.encoding.* |
| import kotlinx.serialization.descriptors.* |
| |
| import java.util.Date |
| import java.text.SimpleDateFormat |
| |
| object DateAsLongSerializer : KSerializer<Date> { |
| override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Date", PrimitiveKind.LONG) |
| override fun serialize(encoder: Encoder, value: Date) = encoder.encodeLong(value.time) |
| override fun deserialize(decoder: Decoder): Date = Date(decoder.decodeLong()) |
| } |
| |
| fun main() { |
| val kotlin10ReleaseDate = SimpleDateFormat("yyyy-MM-ddX").parse("2016-02-15+00") |
| println(Json.encodeToString(DateAsLongSerializer, kotlin10ReleaseDate)) |
| } |