問題:
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