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

LocalDate.parse with formatter does not throw for incorrect date

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      import java.util.*;
      import java.lang.*;
      import java.io.*;
      import java.time.LocalDate;
      import java.time.format.DateTimeFormatter;

      class Issue
      {
      public static void main (String[] args) throws java.lang.Exception
      {
      System.out.println( LocalDate.parse("09/31/2020", DateTimeFormatter.ofPattern("M/d/yyyy")));
      }
      }

      This prints '2020-09-30'. Ideally DateTimeException should be thrown. Happens in sun jdk 1.8.0_51.


      FREQUENCY : always


            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: