When will System.currentTimeMillis() overflow?

后端 未结 6 1663
天涯浪人
天涯浪人 2020-12-01 04:04

I have a web app which orders stuff using a timestamp, which is just a long. My web app backend happens to be written in java, so I am using:

long timestamp          


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 04:47

    It will overflow at

    System.out.println(new Date(Long.MAX_VALUE));
    

    which prints

    Sun Aug 17 03:12:55 GMT-04:00 292278994
    

    That's thus after a bit more than 292 million years. I'd say, there's a plenty of time to invent a solution in the meanwhile. To be honest, I don't expect the humanhood to survive this. We exist only a few seconds as compared to the age of the world in hour scale and it won't take long.

提交回复
热议问题