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

org.apache.tinkerpop.gremlin.ogm.mappers.scalar.InstantPropertyMapper.kt Maven / Gradle / Ivy

There is a newer version: 0.21.0
Show newest version
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