> 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).

Justin Lu has updated the pull request incrementally with one additional commit 
since the last revision:

  Expand explicit dstOffset support during transition periods

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/33235/files
  - new: https://git.openjdk.org/jdk/pull/33235/files/7d860bc5..6b8ff0c3

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=33235&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33235&range=00-01

  Stats: 122 lines in 2 files changed: 107 ins; 0 del; 15 mod
  Patch: https://git.openjdk.org/jdk/pull/33235.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33235/head:pull/33235

PR: https://git.openjdk.org/jdk/pull/33235

Reply via email to