Parsing using the pattern "M/d/yy GGGGG" does not correctly determine the 4 digit year from the 2 digit input.
For a ThaiBuddhistChronology.INSTANCE.date(ThaiBuddhistEra.BE, 2576, 10, 29)
the input of "10/29/76 B.E." is parsed as ThaiBuddhist BE 2076-10-29
For a HijrahChronology.INSTANCE.date(HijrahEra.AH, 1425, 7, 9)
the input "7/9/52 AH" throws an exception:
Exception in thread "main" java.time.format.DateTimeParseException: Text '7/9/25 AH' could not be parsed: Invalid value for YearOfEra (valid values 1300 - 1600): 2025
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1919)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1780)
at bugs.StringConverter.bug2(StringConverter.java:67)
at bugs.StringConverter.main(StringConverter.java:19)
Caused by: java.time.DateTimeException: Invalid value for YearOfEra (valid values 1300 - 1600): 2025
at java.time.temporal.ValueRange.checkValidIntValue(ValueRange.java:327)
at java.time.chrono.Chronology.resolveYearOfEra(Chronology.java:1031)
at java.time.chrono.Chronology.resolveDate(Chronology.java:975)
at java.time.chrono.HijrahChronology.resolveDate(HijrahChronology.java:605)
at java.time.chrono.HijrahChronology.resolveDate(HijrahChronology.java:215)
at java.time.format.Parsed.resolveDateFields(Parsed.java:297)
at java.time.format.Parsed.resolveFields(Parsed.java:252)
at java.time.format.Parsed.resolve(Parsed.java:242)
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1954)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1776)
For a ThaiBuddhistChronology.INSTANCE.date(ThaiBuddhistEra.BE, 2576, 10, 29)
the input of "10/29/76 B.E." is parsed as ThaiBuddhist BE 2076-10-29
For a HijrahChronology.INSTANCE.date(HijrahEra.AH, 1425, 7, 9)
the input "7/9/52 AH" throws an exception:
Exception in thread "main" java.time.format.DateTimeParseException: Text '7/9/25 AH' could not be parsed: Invalid value for YearOfEra (valid values 1300 - 1600): 2025
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1919)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1780)
at bugs.StringConverter.bug2(StringConverter.java:67)
at bugs.StringConverter.main(StringConverter.java:19)
Caused by: java.time.DateTimeException: Invalid value for YearOfEra (valid values 1300 - 1600): 2025
at java.time.temporal.ValueRange.checkValidIntValue(ValueRange.java:327)
at java.time.chrono.Chronology.resolveYearOfEra(Chronology.java:1031)
at java.time.chrono.Chronology.resolveDate(Chronology.java:975)
at java.time.chrono.HijrahChronology.resolveDate(HijrahChronology.java:605)
at java.time.chrono.HijrahChronology.resolveDate(HijrahChronology.java:215)
at java.time.format.Parsed.resolveDateFields(Parsed.java:297)
at java.time.format.Parsed.resolveFields(Parsed.java:252)
at java.time.format.Parsed.resolve(Parsed.java:242)
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1954)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1776)
- relates to
-
JDK-8025828 Late binding of Chronology to appendValueReduced
- Closed