Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8177819

DateTimeFormatterBuilder zone parsing should recognise DST

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b27

      Description

      Given this pattern:

      DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH)

      the appendZoneText(SHORT) method will be called on DateTimeFormatterBuilder. During the DST overlap in Europe/Berlin zone this will print these, one hour apart:

      Sun Oct 30 01:00:00 CEST 2016
      Sun Oct 30 02:00:00 CEST 2016
      Sun Oct 30 02:00:00 CET 2016
      Sun Oct 30 03:00:00 CET 2016

      As can be seen, the text "CEST" or "CET" implies the offset (+02:00 for CEST and +01:00 for CET).

      When parsing, both "CET" and "CEST" are recognised and resolve to ZoneId "Europe/Berlin". But the implied offset is not taken into account. As such, it is not possible to round trip this format, despite all the information being available in the textual form.

      This requires a change to TimeZoneNameUtility.retrieveDisplayNames(), such that it returns not just the display name, but the implied offset (summer time, winter time or generic). When this is used in ZoneTextPrinterParser to find the ZoneId, the extra information (summer/winter/generic) can also be put into DateTimeParserContext. When the context is resolved into a ZonedDateTime/Instant, if the flag is set to summer or winter, the correct offset should be chosen.

      Reference: http://stackoverflow.com/questions/43102957/datetimeformatter-parsing-timezone-names-and-daylight-savings-overlap-times

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              scolebourne Stephen Colebourne
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: