org.apache.tinkerpop.gremlin.ogm.mappers.scalar.InstantPropertyMapper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-gremlin-ogm Show documentation
Show all versions of kotlin-gremlin-ogm Show documentation
The Object Graph Mapping Library for Kotlin and Gremlin
package org.apache.tinkerpop.gremlin.ogm.mappers.scalar
import org.apache.tinkerpop.gremlin.ogm.mappers.PropertyBiMapper
import java.time.Instant
internal object InstantPropertyMapper : PropertyBiMapper {
override fun forwardMap(from: Instant) = "${from.epochSecond}:${from.nano}"
override fun inverseMap(from: String): Instant {
val parts = from.split(':')
val epochSecond = parts[0].toLong()
val nano = parts[1].toLong()
return Instant.ofEpochSecond(epochSecond, nano)
}
override val serializedClass get() = String::class
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy