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

DateTimeFormatter won't parse dates with custom format "yyyyMMddHHmmssSSS"

    Details

    • Subcomponent:
    • Resolved In Build:
      b116
    • OS:
      windows_8

      Description

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


      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1

      A DESCRIPTION OF THE PROBLEM :
      Java 8 produces

      java.time.format.DateTimeParseException: Text '20130812214600025' could not be parsed at index 0

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run this with java 8

      String x = "20130812214600025";
      DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
      LocalDateTime t1 = LocalDateTime.parse(x, dtf);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      parsed successfully
      ACTUAL -
      Exception in thread "main" java.time.format.DateTimeParseException: Text '20130812214600025' could not be parsed at index 0
      at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1948)
      at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1850)
      at java.time.LocalDateTime.parse(LocalDateTime.java:484)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      String x = "20130812214600025";
      DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
      LocalDateTime t1 = LocalDateTime.parse(x, dtf);
      ---------- END SOURCE ----------

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              ntv Nadeesh Tv
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: