com.github.mvv.sredded.impl.EpochMilliSecondAndNanos.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sredded_2.13 Show documentation
Show all versions of sredded_2.13 Show documentation
Structured data representations
The newest version!
package com.github.mvv.sredded.impl
import java.time.temporal.{ChronoField, TemporalAccessor, TemporalField}
final class EpochMilliSecondAndNanos(epochSecond: Long, nanoseconds: Int) extends TemporalAccessor {
override def isSupported(temporalField: TemporalField): Boolean =
temporalField == ChronoField.INSTANT_SECONDS ||
temporalField == ChronoField.MILLI_OF_SECOND ||
temporalField == ChronoField.MICRO_OF_SECOND ||
temporalField == ChronoField.NANO_OF_SECOND
override def getLong(temporalField: TemporalField): Long =
if (temporalField == ChronoField.INSTANT_SECONDS) {
epochSecond
} else if (temporalField == ChronoField.MILLI_OF_SECOND) {
nanoseconds / 1000000
} else if (temporalField == ChronoField.MICRO_OF_SECOND) {
nanoseconds / 1000
} else {
nanoseconds
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy