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?
Asked
Active
Viewed 1.5k times
3 Answers
15
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.

Martijn Courteaux
- 67,591
- 47
- 198
- 287

Tauren
- 26,795
- 42
- 131
- 167
-
2Calendar too uses the *Epoch, January 1, 1970 00:00:00.000 GMT* — so I wonder if a Calendar could handle my birthday. Let alone distant distant past. – Martin May 25 '12 at 07:24
-
use java.time (JSR-310) since Java 8 – Hartmut Pfarr Feb 08 '21 at 18:35
2
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object

Vratislav Jindra
- 551
- 5
- 16

jmj
- 237,923
- 42
- 401
- 438