I have the following Long
variable holding epoch value in seconds, which I\'m trying to convert into a Date
.
val seconds = 1341855763000
I think your time is actually in milliseconds. If I convert 1341855763000
using this website it gives me your expected time and this as well:
fun main() {
val millis = 1341855763000
val date = Date(millis)
println(date)
}
Alternatively, you can also use seconds:
fun main() {
val seconds = 1341855763L
val date = Date(TimeUnit.SECONDS.toMillis(seconds))
println(date)
}
Just divide by 1000
.