All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.serialization.LocalTimeSerializer.kt Maven / Gradle / Ivy

There is a newer version: 0.18.0
Show newest version
package io.fluidsonic.time

import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*


@OptIn(ExperimentalSerializationApi::class)
@Serializer(forClass = LocalTime::class)
public object LocalTimeSerializer : KSerializer {

	override val descriptor: SerialDescriptor =
		PrimitiveSerialDescriptor("kotlinx.datetime.LocalTime", PrimitiveKind.STRING)


	override fun serialize(encoder: Encoder, value: LocalTime) {
		encoder.encodeString(value.toString())
	}


	override fun deserialize(decoder: Decoder): LocalTime =
		LocalTime.parse(decoder.decodeString())
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy