-3

Why does org.apache.commons.lang.time.DateUtils have in its source code a limitation on the number of years?

if (val.get(Calendar.YEAR) > 280000000) {
    throw new ArithmeticException("Calendar value too large for accurate calculations");
}

I wanted to know, why exactly 280 millions, not for exmaple 285. I guessed already, that we won't have java anymore. Also I know, that Long can hold 292278994 years in milliseconds.

OneMore
  • 13
  • 5

2 Answers2

3

Well, I'd have to guess but this is probably related to: When will the java date collapse?

Since year 280,000,000 is very close to the maximum of 292,278,994 there might be any anticipated accuracy problems, hence the message says

Calendar value too large for accurate calculations.

Btw, we now know when the universe is going to end: Sun Aug 17 07:12:55 GMT 292278994 - ;)

Community
  • 1
  • 1
Thomas
  • 87,414
  • 12
  • 119
  • 157
2

As indicated by Thomas there are woes due to date being stored in 64 bits. This guard was introduced in 2004. See the test case for details and also bug LANG-24.

kmkaplan
  • 18,655
  • 4
  • 51
  • 65