Java Converting 19-digit Unix Timestamp to a Readable Date

后端 未结 3 2124
旧时难觅i
旧时难觅i 2021-01-26 11:26

I am trying to convert 19 digit Unix timestamp such as 1558439504711000000 (one and a half quintillion) into a readable date/time format. My timestamp ends with 6 z

3条回答
  •  孤独总比滥情好
    2021-01-26 12:16

    I think there is nothing wrong with that, you are dealing with a timestamp that represent a date in the FUTURE (a really far away date in the future).

    If you consider this:

    String timeStamp = "1558439504";

    this should give you: 05/21/2019 @ 11:51am (UTC)

    Then there is I think an easy way to get the Date. Just create the Instant first based on that timestamp and then do:

    Date myDate = Date.from(instant);
    

提交回复
热议问题