public Date parse(String text) throws ParserException {
  text=text.trim();
  int length=text.length();
  if (length == LONG_DATE_FORMAT.length()) {
    return parse(text,LONG_DATE_FORMAT);
  }
  if (length == MEDIUM_DATE_FORMAT.length()) {
    return parse(text,MEDIUM_DATE_FORMAT);
  }
  return parse(text,SHORT_DATE_FORMAT);
}

public Date parse ( String text ) throws ParserException { text = text . trim ( ) ; int length = text . length ( ) ; if ( length == LONG_DATE_FORMAT . length ( ) ) { return parse ( text , LONG_DATE_FORMAT ) ; } if ( length == MEDIUM_DATE_FORMAT . length ( ) ) { return parse ( text , MEDIUM_DATE_FORMAT ) ; } return parse ( text , SHORT_DATE_FORMAT ) ; }
will try to parse the date with locale . us and formats as follows : yyyy - mm - dd hh : mm : ss . sss , yyyy - mm - dd hh : mm : ss and yyyy - mm - dd
