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

DateTimeFormatter does not parse LocalDate/LocalDateTime correctly

    Details

    • Subcomponent:
    • Introduced In Build:
      b01
    • Introduced In Version:
      11
    • CPU:
      x86_64

      Description

      ADDITIONAL SYSTEM INFORMATION :
      OS : Windows 10
      JRE : 11.8 and 11.9

      A DESCRIPTION OF THE PROBLEM :
      Using the following code on JDK 11.8/11.9 -
      LocalDate dt = LocalDate.now();
      String dtStr= dt.format(DateTimeFormatter.ofPattern("dd-MMM-yyyy"));

      Output is -

      dt= 2020-11-20
      dtStr = 20-Nov.-2020

      Notice the "." in dtStr which is incorrect.
      LocalDateTime with the same format pattern("dd-MMM-yyyy") also yields the "." in the resultant string.

      The same error is not observed on JDK 8. I have not tested with JDK>11.

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the following code snippet -
      LocalDate dt = LocalDate.now();
      String dtStr= dt.format(DateTimeFormatter.ofPattern("dd-MMM-yyyy"));

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      dt= 2020-11-20
      dtStr = 20-Nov-2020
      ACTUAL -
      dt= 2020-11-20
      dtStr = 20-Nov.-2020

      CUSTOMER SUBMITTED WORKAROUND :
      Using substring at the moment to overcome the "." in the resultant string.

      FREQUENCY : always


        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: