dawidhyzy
06/21/2023, 7:45 AMJSJoda.Instant
and Instant
?dawidhyzy
06/21/2023, 7:49 AMprivate fun Instant.toJsInstant() = InstantJs.ofEpochMilli(toEpochMilliseconds())
private fun InstantJs.toInstant() = Instant.fromEpochMilliseconds(toEpochMilli().toLong())
I created two extension functions but I’m wondering if there is a better way to do that.Dmitry Khalanskiy [JB]
06/21/2023, 8:01 AMprivate fun Instant.toJsInstant() = InstantJs.ofEpochSecond(epochSeconds, nanosecondsOfSecond)
private fun InstantJs.toInstant() = Instant.fromEpochSeconds(epochSecond().toLong(), nano().toInt())
This will also preserve the nanosecond portion.