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

DateTimeFormatterBuilder zone parsing should recognise DST

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • core-libs
    • None
    • behavioral
    • low
    • 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.
    • Java API
    • SE

      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:

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

              Created:
              Updated:
              Resolved: