co.saltpay.epos.models.serializers.TimeZoneSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of epos-core-models Show documentation
Show all versions of epos-core-models Show documentation
Internal lib to handle epos requests.
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)
}