java 1970 年 1 月 1 日之前的日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3706937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dates before January 1st, 1970
提问by user339108
The getTime()fetches the time in millis for a certain Date. Can this be used reliably for dates say in the 18th century. We use the millis and store it in a string variable for future comparison. Is there a limit on how far in the past that this could be used?
该的getTime()获取以毫秒为某一特定日期时间。这可以可靠地用于 18 世纪的日期吗?我们使用millis并将其存储在字符串变量中以供将来比较。过去可以使用多远有限制吗?
采纳答案by Tauren
I would highly recommend you take a look at JodaTimeif you are doing date/time comparisons of the distant past. Or actually any sort of date/time comparisons and calculations. It is a great library!
如果您正在对遥远的过去进行日期/时间比较,我强烈建议您查看JodaTime。或者实际上任何类型的日期/时间比较和计算。这是一个很棒的图书馆!
Don't rely on getTime() for what you want to do. At least consider using Java's Calendar/GregorianCalendar. But personally, I'd suggest using JodaTime.
不要依赖 getTime() 来做你想做的事。至少考虑使用 Java 的Calendar/GregorianCalendar。但就个人而言,我建议使用 JodaTime。
回答by MarrLiss
Of course, long is signed and for example 1.1.1701 is -8 488 782 000 000.
当然,long 是有符号的,例如 1.1.1701 是 -8 488 782 000 000。