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

Date is absolutely unparsabel no matter which parse string

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 17
    • core-libs
    • x86_64
    • windows

      ADDITIONAL SYSTEM INFORMATION :
      java version "17.0.1" 2021-10-19 LTS
      Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      It is absolutely impossible to parse any date in the format dd.MM.yyyy.

      This code:
          public static void main(String[] args) throws ParseException {
              String d = "22.07.2024";
              SimpleDateFormat parser = new SimpleDateFormat("d.M.y"); // or when using dd.MM.yyyy instead
              System.out.println(parser.parse(d));
          }

      Produces this error:
      java.text.ParseException: Unparseable date: "22.07.2024"

      REGRESSION : Last worked in version 8u421

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run above mentioned code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Date is parsed from String to java.util.Date
      ACTUAL -
      A totally false error message is thrown when no actual error occured:
      java.text.ParseException: Unparseable date: "22.07.2024"

      ---------- BEGIN SOURCE ----------
      import java.text.ParseException;
      import java.text.SimpleDateFormat;

      public class Test {
          public static void main(String[] args) throws ParseException {
              String d = "22.07.2024";
              SimpleDateFormat parser = new SimpleDateFormat("d.M.y");
              System.out.println(parser.parse(d));
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            rkale Raghu Kale
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: