I want to validate the date in the format yyyy-MM-dd. If i give two digits for year (ie YY instead of YYYY) it is not throwing any exception and 00 is getting appended to the date time format on parsing the date.
I have added setLenient(false);
, but still it is not validating correctly.
Can anyone please help me on this?
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
formatter.setLenient(false);
try {
Date date = (Date)formatter.parse("15-05-30"); //In this line year is getting appened with 00 and becomes 0015
reciptDate = dateFormat.format(date);
} catch (ParseException pe) {
return false;
}