DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
System.out.println(df.parse("32/12/2016"));
System.out.println(df.parse("30/02/2017"));
System.out.println(df.parse("31/11/2016"));
I'm expecting all the above scenarios as ParseException
but but I'm getting output as below:
Sun Jan 01 00:00:00 GMT 2017
Thu Mar 02 00:00:00 GMT 2017
Thu Dec 01 00:00:00 GMT 2016
In my case all the above scenarios are validation failed one.
Note: I can't do equals(post and pre parse the date.) also why because my date inputs may come as DD/MM/YYYY or D/M/YY.
Is there any other way to do this?