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

model.ZoneIdBSONCodec.kt Maven / Gradle / Ivy

There is a newer version: 0.9.27
Show newest version
package com.github.fluidsonic.baku

import org.bson.BsonReader
import org.bson.BsonWriter
import java.time.ZoneId


internal object ZoneIdBSONCodec : AbstractBSONCodec(includesSubclasses = true) {

	override fun BsonReader.decode(context: BSONCodingContext) =
		readString().let { id ->
			ZoneId.of(id) ?: error("invalid timezone: $id")
		}


	override fun BsonWriter.encode(value: ZoneId, context: BSONCodingContext) {
		writeString(value.id)
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy