Get java.util.Calendar from days since epoch

后端 未结 3 1653
清酒与你
清酒与你 2021-01-18 15:53

I have a variable containing the days since the epoch reference date of 1970-01-01 for a certain date.

Does someone know the way to convert this variabl

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 15:56

    Use the java.time classes in Java 8 and later. In one line:

    LocalDate date = LocalDate.ofEpochDay(1000);
    

    Calling ofEpochDay(long epochDay) obtains an instance of LocalDate from the epoch day count.

提交回复
热议问题