JDK-8225026 : DateTimeFormatter Fails to throw an Exception on Invalid HOUR_OF_AMPM
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.time
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 13
  • Submitted: 2019-05-29
  • Updated: 2019-05-31
  • Resolved: 2019-05-31
Related Reports
CSR :  
Description
Summary
-------

Throw a `DateTimeParseException` on resolving an out-of-range `HOUR_OF_AMPM` value in `ResolverStyle.SMART mode.

Problem
-------

Client code like this:

    new DateTimeFormatterBuilder()
        .appendValue(HOUR_OF_AMPM,2)
        .appendText(AMPM_OF_DAY)
        .toFormatter(US)
        .parse("12PM");

does not throw a `DateTimeParseException`, even though the input hour number `12` is out of range for `HOUR_OF_AMPM`.

Solution
--------

Throw a `DateTimeParseException` in such cases.

Specification
-------------

This is a behavioral change, thus no specification change is expected.



Comments
Moving to Approved.
31-05-2019