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

LocalDateTime.parse(str, frmt) fails with Unable to obtain from TemporalAccessor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 8
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.8.0-ea"
      Java(TM) SE Runtime Environment (build 1.8.0-ea-b108)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b50, mixed mode)

      FULL OS VERSION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      trying to create a Offset/LocalDateTime object from a given date/time string and a date/time format based on Patterns for Formatting and Parsing from DateTimeFormatter fails when attempting to parse the ZoneOffset value

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create the string variable containing the actual Date/Time

          private String strDate = "2013-06-14T12:04:36.454-04:00";

      Create the string variable holding the pattern to be used by the formatter

          private static String datePattern = "yyyy-MM-dd'T'hh:mm:ss.SSSXXX";

      Create the DateTimeFormatter object

          private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(datePattern);

      Attempt to create a LocalDateTime object from the strDate and dateFormatter

          private LocalDateTime ldtDate = LocalDateTime.parse(strDate, dateFormatter);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      When it seems that the Pattern syntax is correct to read the given string the following Error is thrown

      Text '2013-06-14T12:04:36.454-04:00' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: class java.time.format.Parsed
      file:/D:/Oracle/Projects/UltraLogMiner/dist/run641707932/UltraLogMiner.jar!/com/ultra/log/miner/fxml/UltraLogMiner.fxml:14
        at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1919)
        at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1854)
        at java.time.LocalDateTime.parse(LocalDateTime.java:483)
        at com.my.program....
      REPRODUCIBILITY :
      This bug can be reproduced always.

            rriggs Roger Riggs
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: