Timestamp Epoch to LocalDateTime / Java8 Date Time

July 22, 2019

Milliseconds to LocalDateTime

val millis = 1563778672919L
val date = LocalDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneId.systemDefault())

Milliseconds to LocalDateTime (UTC)

val millis = 1563778672919L
val date = LocalDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.UTC)

Seconds to LocalDateTime

val seconds = 1563778672
val date = LocalDateTime.ofInstant(Instant.ofEpochSecond(seconds), ZoneId.systemDefault())

NOTE: LocalDateTime To Timestamp Epoch Seconds And Milliseconds

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.