How can I create a Java 8 LocalDate from a long Epoch time in Milliseconds?

后端 未结 6 1440
一整个雨季
一整个雨季 2020-11-28 02:15

I have an external API that returns me dates as longs, represented as milliseconds since the beginning of the Epoch.

With the old style Java API, I woul

6条回答
  •  一个人的身影
    2020-11-28 02:54

    Timezones and stuff aside, a very simple alternative to new Date(startDateLong) could be LocalDate.ofEpochDay(startDateLong / 86400000L)

提交回复
热议问题