SimpleDateFormat.parse() accepts the date 003/1/2011 when the format is MM/dd/yyyy. Trying with code below:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(false);
Date dt2;
try
{
dt2 = sdf.parse(_datemmddyyyy);
}
catch (ParseException e)
{
return false;
}
and the date is parsed as 00/11/2011. What is wrong?
Are you sure? This:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(false);
Date dt2 = sdf.parse("003/1/2011");
System.out.println(dt2);
Yields:
Tue Mar 01 00:00:00 PST 2011
That's 03/01/2001 in MM/dd/yyyy. Seems right?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With