When I create a Date object after parsing like...
String eDate = "27-AUG-24";
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
ParsePosition pos = new ParsePosition(0);
sdf.setLenient(false);
java.util.Date endDate = sdf.parse(eDate, pos);
System.out.println(endDate);
When printing the endDate I get the date as
Wed Aug 27 00:00:00 GMT+05:30 1924
Works fine till 26-AUG-24.
But when I do the same after changing the date format like...
String eDate = "27-AUG-2024";
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
ParsePosition pos = new ParsePosition(0);
sdf.setLenient(false);
java.util.Date endDate = sdf.parse(eDate, pos);
System.out.println(endDate);
Here I get correct results.
Tue Aug 27 00:00:00 GMT+05:30 2024
Why is there a descrepancy between the two parsing formats?