Time conversion from seconds to date issue

后端 未结 4 1172
慢半拍i
慢半拍i 2021-01-29 09:23

I have the following Long variable holding epoch value in seconds, which I\'m trying to convert into a Date.

val seconds = 1341855763000         


        
4条回答
  •  无人共我
    2021-01-29 10:16

    The value you have is not in seconds but in milliseconds. Remove the "seconds to millis" conversion.

    val milliSeconds = 1341855763000
    val date = Date(milliSeconds)
    

提交回复
热议问题