jdk8Main.common.Timestamp.jvm.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-time-jdk8 Show documentation
Show all versions of fluid-time-jdk8 Show documentation
Multiplatform date & time library
package io.fluidsonic.time
actual fun Timestamp.toDayOfWeek(timeZone: TimeZone) =
toPlatform().atZone(timeZone.toPlatform()).dayOfWeek.toCommon()
actual fun Timestamp.toLocalDate(timeZone: TimeZone) =
toPlatform().atZone(timeZone.toPlatform()).toLocalDate().toCommon()
actual fun Timestamp.toLocalDateTime(timeZone: TimeZone) =
toPlatform().atZone(timeZone.toPlatform()).toLocalDateTime().toCommon()
actual fun Timestamp.toLocalTime(timeZone: TimeZone) =
toPlatform().atZone(timeZone.toPlatform()).toLocalTime().toCommon()
fun Timestamp.toPlatform(): PlatformTimestamp =
PlatformTimestamp.ofEpochSecond(secondsSince1970.toLong(), partialNanosecond.toLong())
fun PlatformTimestamp.toCommon() =
Timestamp.of(secondsSince1970 = Seconds(epochSecond), nanoseconds = Nanoseconds(nano))