16

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?

user339108
  • 12,613
  • 33
  • 81
  • 112

3 Answers3

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
12

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

MarrLiss
  • 808
  • 5
  • 10
2

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object

Better to go for Calendar OR Jodatime

Vratislav Jindra
  • 551
  • 5
  • 16
jmj
  • 237,923
  • 42
  • 401
  • 438