Java: Date from unix timestamp

后端 未结 10 1725
北荒
北荒 2020-11-22 04:10

I need to convert a unix timestamp to a date object.
I tried this:

java.util.Date time = new java.util.Date(timeStamp);

Timestamp value

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 04:33

    Date's constructor expects the timeStamp value to be in milliseconds. Multiply your timestamp's value with 1000, then pass it to the constructor.

提交回复
热议问题