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

scalapb.TimestampConverters.scala Maven / Gradle / Ivy

The newest version!
package scalapb

import java.time.Instant

import scala.language.implicitConversions

import com.google.protobuf.timestamp.Timestamp

trait TimestampConverters {
  implicit def fromJavaInstant(instant: Instant): Timestamp =
    Timestamp(seconds = instant.getEpochSecond, nanos = instant.getNano)

  implicit def asJavaInstant(timestamp: Timestamp): Instant =
    Instant.ofEpochSecond(timestamp.seconds).plusNanos(timestamp.nanos.toLong)
}

object TimestampConverters extends TimestampConverters




© 2015 - 2024 Weber Informatics LLC | Privacy Policy