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

问题:

I have an external API that returns me dates as long s, represented as milliseconds since the beginning of the Epoch.我有一个外部 API,它返回我作为long s 的日期,表示为自 Epoch 开始以来的毫秒数。

With the old style Java API, I would simply construct a Date from it with使用旧式 Java API,我只需从它构造一个Date

Date myDate = new Date(startDateLong)

What is the equivalent in Java 8's LocalDate / LocalDateTime classes? Java 8 的LocalDate / LocalDateTime类中的等价物是什么?

I am interested in converting the point in time represented by the long to a LocalDate in my current local timezone.我有兴趣将long表示的时间点转换为当前本地时区中的LocalDate


解决方案:

参考一: https://en.stackoom.com/question/2Nck6
参考二: https://stackoom.com/question/2Nck6
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章