On Tue, 6 Oct 2026 22:09:22 GMT, Justin Lu <[email protected]> wrote: > This PR targets a parsing inconsistency for `SimpleDateFormat` when using > explicit `dstOffset`. > > Currently, `SimpleDateFormat` formatting applies the explicit `dstOffset` > logic when applicable. However, parsing does not consult the explicit > `dstOffset`, and uses the name in the text to derive whether daylight is in > effect or not. This can create round trip inconsistencies. > > For example, > > > // Historical daylight offset: +00:34:39 > Date.from(Instant.parse("1916-07-15T00:00:00Z")), > // Formats to -> 1916-07-15 00:34:39 Greenwich Mean Time > // ------------- > // Historical standard offset: −00:25:21 > Date.from(Instant.parse("1916-01-15T00:00:00Z")), > // Formats to -> 1916-01-14 23:34:39 Greenwich Mean Time > > > Both formatting calls produce "Greenwich Mean Time" in the text, even though > the first is in daylight. The second case can round trip because because it > uses the name to determine standard time. For the first case, the old code > uses "Greenwich Mean Time" to determine standard time during parsing, even > though the offset at that date is in daylight time. This produces the > mismatched `Date`s. This PR updates the parsing path to not set the > `DST_OFFSET` based on the name, but rather let the `Calendar` naturally > derive the correct offset from the zone when an explicit `dstOffset` is used. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
This pull request has now been integrated. Changeset: d75a38d1 Author: Justin Lu <[email protected]> URL: https://git.openjdk.org/jdk/commit/d75a38d1d88dab025addf0183b000734f38cfb86 Stats: 479 lines in 3 files changed: 310 ins; 153 del; 16 mod 8392991: SimpleDateFormat CLDR zone name format and parse can change the instant Reviewed-by: naoto ------------- PR: https://git.openjdk.org/jdk/pull/33235
