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

后端 未结 6 1433
一整个雨季
一整个雨季 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:45

    In a specific case where your epoch seconds timestamp comes from SQL or is related to SQL somehow, you can obtain it like this:

    long startDateLong = <...>
    
    LocalDate theDate = new java.sql.Date(startDateLong).toLocalDate();
    

提交回复
热议问题