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

DateTimeFormatterBuilder zone parsing should recognise DST

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Apps that always expect the DST parsing at the overlap may see a different offset, but the risk is low as it is rare, only occurs usually for one hour in the whole year.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Parsing dst aware zone name should choose the zone offset correctly for date/time at the dst->std overlap.

      Problem

      When parsing a date/time string at dst->std overlap, the current implementation always chooses the dst offset, even if the source string contains non-DST zone name.

      Solution

      If the source string contains non-DST zone name, and without any explict offset (such as "+0100"), parsing should choose standard offset, instead of daylight saving offset.

      Specification

      In java.time.format.DateTimeFormatter's class description, change the number 10 item in the numbered list at "Resolving" section as follows:

         * the field {@link ChronoField#INSTANT_SECONDS} is created.
         * If an offset was parsed then the offset will be combined with the
         * {@code LocalDateTime} to form the instant, with any zone ignored.
         * If a {@code ZoneId} was parsed without an offset then the zone will be
         * combined with the {@code LocalDateTime} to form the instant using the rules
      -  * of {@link ChronoLocalDateTime#atZone(ZoneId)}.
      +  * of {@link ChronoLocalDateTime#atZone(ZoneId)}. If the {@code ZoneId} was
      +  * parsed from a zone name that indicates whether daylight saving time is in
      +  * operation or not, then that fact will be used to select the correct offset
      +  * at the local time-line overlap.
         * </ol>
         *
         * @implSpec
         * This class is immutable and thread-safe.
         *

      Additionally, fix the following typos:

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              scolebourne Stephen Colebourne
              Reviewed By:
              Joe Wang, Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: