Can anybody help?
public void dateCalender() throws ParseException{
System.out.println(new SimpleDateFormat(\"MM/dd/yyyy\", Locale.ENGLISH).parse(\"120/1
According to docs , parsing is lenient, So you didn't get exception for invalid input. It converted to another value.
By default, parsing is lenient: If the input is not in the form used by this object's format method but can still be parsed as a date, then the parse succeeds. Clients may insist on strict adherence to the format by calling setLenient(false).
If you want to get java.text.ParseException: Unparseable date:
, than apply setLenient(false);
at SimpleDateFormat
String dateStr="120/12/2013";
SimpleDateFormat sdf=new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
sdf.setLenient(false);
try {
Date d=sdf.parse(dateStr);
} catch (ParseException ex) {
ex.printStackTrace();
}