Java中的最小日期 [英] Minimum date in Java

查看:1119
本文介绍了Java中的最小日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java中的最小日期值是多少?

What is the minimum date value in Java?

推荐答案

不要忘记Date构造函数愉快地接受负值。 / p>

Don't forget that Date constructor happily accepts negative values.

Date date = new Date(Long.MIN_VALUE);

返回


Sun Dec 02 22:47:04 BDT 292269055

Sun Dec 02 22:47:04 BDT 292269055

我猜这是关于大爆炸的时间>恐龙:)

I guess that's about the time of Big Bang dinosaurs :)

编辑

As martin clayton 回答,你可以使用Calendar类检查时代。这将输出0代表BCE:

As martin clayton answered, you can use the Calendar class to check the era. This will output 0 which stands for BCE:

Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(Long.MIN_VALUE));
System.out.println(calendar.get(Calendar.ERA));

这篇关于Java中的最小日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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