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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章