I have two date formats :
"yyyy-MM-dd", "dd-MM-yyyy"
But when I am trying to parse the date :"11-05-2021"
, it is not throwing exception for "yyyy-MM-dd"
format. Below is the thing which I am trying to do :
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
sdf.parse(d);
} catch (Exception e) {
e.printStackTrace();
}
Why it is not giving the exception for "yyyy-MM-dd"
format . How it can be differentiated between the two formats ?
Thanks