Here is an example:
public MyDate() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy/MM/d\");
sdf.setLenient(false);
St
Take a look on the method documentation which says: ParseException if the beginning of the specified string cannot be parsed.
Method source code with javadoc:
/**
* Parses text from the beginning of the given string to produce a date.
* The method may not use the entire text of the given string.
*
* See the {@link #parse(String, ParsePosition)} method for more information
* on date parsing.
*
* @param source A String whose beginning should be parsed.
* @return A Date parsed from the string.
* @exception ParseException if the beginning of the specified string
* cannot be parsed.
*/
public Date parse(String source) throws ParseException
{
ParsePosition pos = new ParsePosition(0);
Date result = parse(source, pos);
if (pos.index == 0)
throw new ParseException("Unparseable date: \"" + source + "\"" ,
pos.errorIndex);
return result;
}