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

DateTimeFormatter does not work correctly for the range 29-31.12.2024

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Example code written in scala
      ```
          val formatter = DateTimeFormatter.ofPattern("YYY-MM-dd")
          List.range(28, 32).foreach { day =>
            assertEquals(
              LocalDate.of(2024, 12, day).format(formatter),
              s"2024-12-$day"
            )
          }
      ```

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the linked code, for the date 29.12.2024, 30.12.2024 and 31.12.2024

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      for the date 29.12.2024, 30.12.2024 and 31.12.2024 results I expect 2024-12-29, 2024-12-30, 2024-12-31
      ACTUAL -
      for the date 29.12.2024, 30.12.2024 and 31.12.2024 results are 2025-12-29, 2025-12-30, 2025-12-31

      ---------- BEGIN SOURCE ----------
          val formatter = DateTimeFormatter.ofPattern("YYY-MM-dd")
          List.range(28, 32).foreach { day =>
            assertEquals(
              LocalDate.of(2024, 12, day).format(formatter),
              s"2024-12-$day"
            )
          }
      ---------- END SOURCE ----------

            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: