什么时候java日期会崩溃? [英] When will the java date collapse?

查看:163
本文介绍了什么时候java日期会崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AFAIK java以长度变量存储日期,以毫秒为单位。因此,有一天,没有价值(因为长有一个最大值),这将对应于那一瞬间的时间。你知道什么时候会发生吗?

AFAIK java stores dates in long variables as milliseconds. Consequently someday there will be no value (cause long has a maximum) which will correspond to the time of that instant. Do you know when it will happen?

推荐答案

很容易找出来:

public class Test {
    public static void main(String[] args) {
        System.out.println(new java.util.Date(Long.MAX_VALUE));
    }
}

提供输出(在我的框上):

Gives output (on my box):

Sun Aug 17 07:12:55 GMT 292278994

您可能需要从 Long.MAX_VALUE 中减去一点,以应对您的时区溢出的范围,但会给一个合理的球场:)

You may need to subtract a bit from Long.MAX_VALUE to cope with your time zone overflowing the range of long, but it will give a reasonable ballpark :)

这篇关于什么时候java日期会崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆