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

Unexpected DateTimeParseException Conflict found: HourOfDay 19 differs from HourOfDay 0 while resolving NanoOfDay

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      java version "1.8.0_172"
      Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      DateTimeFormatter raises an exception on certain patterns and input strings.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception.
      ACTUAL -
      java.time.format.DateTimeParseException: Text '2018-09-19T19:16:13' could not be parsed: Conflict found: HourOfDay 19 differs from HourOfDay 0 while resolving NanoOfDay

      ---------- BEGIN SOURCE ----------
      import java.time.*;
      import java.time.format.*;
      import java.time.temporal.*;
      import java.util.*;

      public class ConflictHourOfDay {

          public static void main(String args[]) {
              int retval = 1;
              try {
                  DateTimeFormatter inputDateTimeFormatter = new DateTimeFormatterBuilder()
                                 .appendPattern("yyyy-MM-dd'T'HH:mm:ss")
                                 .parseDefaulting(ChronoField.NANO_OF_DAY, 0)
                                 .toFormatter(Locale.ROOT)
                                 .withZone(ZoneOffset.UTC);
                  ZonedDateTime dateTime = ZonedDateTime.parse("2018-09-19T19:16:13", inputDateTimeFormatter);
                  System.out.printf("%s%n", dateTime);
                  retval = 0;
              } catch (Exception e) {
                  e.printStackTrace();
              }
              System.exit(retval);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Unknown.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              naoto Naoto Sato
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: