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

co.saltpay.epos.models.serializers.TimeZoneSerializer.kt Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
package co.saltpay.epos.models.serializers

import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.util.*

internal object TimeZoneSerializer : KSerializer {
    override fun deserialize(decoder: Decoder): TimeZone {
        return TimeZone.getTimeZone(decoder.decodeString())
    }

    override fun serialize(encoder: Encoder, value: TimeZone) {
        encoder.encodeString(value.id)
    }

    override val descriptor: SerialDescriptor
        get() = PrimitiveSerialDescriptor("TimeZone", PrimitiveKind.STRING)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy