RFR: 8364752: Class java.time.Instant cannot parse all ISO 8601 date formats [v7]

Roger Riggs rriggs at openjdk.org
Tue Aug 19 18:24:39 UTC 2025


On Mon, 18 Aug 2025 19:19:08 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> `Instant.parse()` is expected to use the offset zone pattern `+HH:mm:ss` (as defined by `DateTimeFormatterBuilder.appendOffsetId()`), but it fails to parse hour-only offsets such as `+02`. This is because the actual implementation uses `+HH:MM:ss` as the pattern. While replacing the pattern in the implementation as with the specification would allow hour-only offsets, it would also introduce compatibility issues, i.e., printing would omit the minutes field when it is zero. So, it is preferable to update the specification to match the implementation. A CSR has also been drafted for this change.
>
> Naoto Sato has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains nine additional commits since the last revision:
> 
>  - DateTimeFormatterBuilder wording
>  - Added non-zero offset test cases
>  - Merge branch 'master' into JDK-8364752-Instant-ISO8601
>  - Update src/java.base/share/classes/java/time/format/DateTimeFormatter.java
>    
>    Right. Changing to your suggested wording
>    
>    Co-authored-by: Roger Riggs <Roger.Riggs at Oracle.com>
>  - copyright year update
>  - test cases
>  - allow all ISO 8601 offsets
>  - allow hour-only offsets
>  - initial commit

Looks good, thanks for the explanation of the parsing format.

-------------

Marked as reviewed by rriggs (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26708#pullrequestreview-3133368081


More information about the core-libs-dev mailing list