RFR: 8210336: DateTimeFormatter predefined formatters should support short time zone offsets [v3]

Justin Lu jlu at openjdk.org
Tue Jan 27 23:31:06 UTC 2026


On Tue, 27 Jan 2026 21:22:28 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> This PR is a follow-on fix to [JDK-8032051](https://bugs.openjdk.org/browse/JDK-8032051), where it allowed short offsets only for ZonedDateTime parsing. This fix allows all predefined ISO formatters to accept short offsets. A corresponding CSR has been drafted.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Modified the test to cover all ISO formatters (sans *LOCAL*), not only the changed ones

The impl and spec changes look consistent with [JDK-8032051](https://bugs.openjdk.org/browse/JDK-8032051). I see that `ISO_INSTANT` does not need the fix due to [JDK-8365182](https://bugs.openjdk.org/browse/JDK-8365182). This change looks good to me.

test/jdk/java/time/test/java/time/format/TestDateTimeFormatter.java line 361:

> 359:     @ParameterizedTest
> 360:     @MethodSource("data_iso_short_offset_parse")
> 361:     public void test_iso_short_offset_parse(String text, DateTimeFormatter formatter) {

Even though this is primarily a parsing test, since we are already adding a test, I think it would not hurt to also check the "+/-00" shorthand offset cases. (Since the formatted text would take a different form than a non zero hour only offset.)

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

Marked as reviewed by jlu (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29393#pullrequestreview-3713862331
PR Review Comment: https://git.openjdk.org/jdk/pull/29393#discussion_r2734178642


More information about the core-libs-dev mailing list