SimpleDateFormat df
=
new
SimpleDateFormat(
"
MMddyyyy
"
);
/*
* With lenient parsing, the parser may use heuristics to interpret inputs that
* do not precisely match this object's format.
* With strict parsing, inputs must match this object's format.
*/
df.setLenient( false );
try {
Date a = df.parse( " 23232011 " );
System.out.print( " date: " + a);
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*
* With lenient parsing, the parser may use heuristics to interpret inputs that
* do not precisely match this object's format.
* With strict parsing, inputs must match this object's format.
*/
df.setLenient( false );
try {
Date a = df.parse( " 23232011 " );
System.out.print( " date: " + a);
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}