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

DateTimeFormatter throw a NullPointerException when parsing Zone id or name

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b63)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b63, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux ananas 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Parsing a date from a String with a pattern containing a zone id or zone pattern throw a DateTimeParseException with a NullPointerException as a root cause.

      REGRESSION. Last worked in version 8u25

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      parse a date based on a format with a zone name or zone id.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Return a ZonedDateTime with the correct value.
      ACTUAL -
      Throw a DateTimeParseException exception.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.time.format.DateTimeParseException: Text '20150128 12:03:56 PST' could not be parsed: null
      at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
      at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
      at java.time.ZonedDateTime.parse(ZonedDateTime.java:598)
      at org.sfm.csv.impl.CellValueReaderFactoryImplTest.testJavaZonedDateTime(CellValueReaderFactoryImplTest.java:120)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
      Caused by: java.lang.NullPointerException
      at java.time.format.DateTimeFormatterBuilder$PrefixTree.prefixLength(DateTimeFormatterBuilder.java:4137)
      at java.time.format.DateTimeFormatterBuilder$PrefixTree.add0(DateTimeFormatterBuilder.java:4006)
      at java.time.format.DateTimeFormatterBuilder$PrefixTree.add(DateTimeFormatterBuilder.java:4001)
      at java.time.format.DateTimeFormatterBuilder$ZoneTextPrinterParser.getTree(DateTimeFormatterBuilder.java:3752)
      at java.time.format.DateTimeFormatterBuilder$ZoneIdPrinterParser.parse(DateTimeFormatterBuilder.java:3859)
      at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.parse(DateTimeFormatterBuilder.java:2212)
      at java.time.format.DateTimeFormatter.parseUnresolved0(DateTimeFormatter.java:2010)
      at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1939)
      at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
      ... 28 more

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
         String date = "20150128 12:03:56 PST";
          final DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss z");
          java.time.ZonedDateTime localTime = java.time.ZonedDateTime.parse(date, yyyyMMdd);
       
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      seemed to be working with a -08:30 instead of the zone name.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: