JDK-8067800 : Clarify java.time.chrono.Chronology.isLeapYear for out of range years
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-12-17
  • Updated: 2017-05-17
  • Resolved: 2015-02-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u101Fixed 9 b51Fixed
Related Reports
Relates :  
The spec says that the method isLeapYear(long prolepticYear) accepts as parameter  prolepticYear which is not validated for range.


But f.e. in the case of using one of the following values 1004, 1008, 1012, 2000, 400, 4, 400000000, 0, 96, -4, -400000000 as parameter the unexpected DateTimeException is thrown:

java.time.DateTimeException: Hijrah date out of range

Tests belonging to the JCK9 suite (not yet integrated) will fail due to this issue: api/java_time/chrono/HijrahChronology/index.html#IsLeapYear 

(not integrated yet)

After some discussion, an alternate solution is proposed. The java.time.chrono.Chronology.isLeapYear method will be clarified to require correct leap year results for the year range supported by the calendar and recommend a best effort value or false outside the range.

All of the other methods that operate on Hijrah dates are checked for a valid range and throw DateTimeException. Throwing an exception will prevent an incorrect value (25% of the time) from being returned and propagated into application code. The observed ArrayIndexOutOfBoundException is a bug in the year range checking. The specification for HijrahChronology should specify that the range of the calendar variants is limited by the available calendar data and DateTimeException is thrown if data is not available for a year, month, or day.

To meet the spec, I propose that dates outside the supported range return false.