Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dates before January 1st, 1970

Tags:

java

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?

like image 613
user339108 Avatar asked Sep 14 '10 07:09

user339108


2 Answers

I would highly recommend you take a look at JodaTime if 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!

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.

like image 73
Tauren Avatar answered Oct 19 '22 21:10

Tauren


Of course, long is signed and for example 1.1.1701 is -8 488 782 000 000.

like image 32
MarrLiss Avatar answered Oct 19 '22 20:10

MarrLiss