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

DateTimeFormatter fail to parse time string when seconds and milliseconds are 0s

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 10.0.1
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      A DESCRIPTION OF THE PROBLEM :
      As already mention in this Question in

      StackOveflow https://stackoverflow.com/questions/49967139/java-datetimeformatter-fail-to-parse-time-string-when-seconds-and-milliseconds

      This piece of code should return for this "20180301091600000" with this "yyyyMMddHHmmssSSS" patter a result : "2018-03-01T09:16:00.000" note the last part "00.000" for seconds and milliseconds.
      Instead it return "2018-03-01T09:16".


      REGRESSION : Last worked in version 10.0.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      DateTimeFormatter dtformatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
      var result = LocalDateTime.parse("20180301091600000", dtformatter);
      System.out.println(result);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      2018-03-01T09:16:00.000
      ACTUAL -
      2018-03-01T09:16

      CUSTOMER SUBMITTED WORKAROUND :
      A temporary solution is like I mentioned here https://stackoverflow.com/a/49967274/5558072

      We need to parse the date with another formatter like this :

      var result = LocalDateTime.parse("20180301091600001", dtformatter)
                                          .format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss:SSS"));

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: