public static Date parseDate(String dateStr){
  String formatString="";
  if (dateStr.length() == 16)   dateStr=dateStr.substring(0,14);
  if (dateStr.length() == 15)   formatString="yyyyMMdd'T'hhmmss";
  if (dateStr.length() == 8)   formatString="yyyyMMdd";
  SimpleDateFormat formatter=new SimpleDateFormat(formatString);
  ParsePosition pos=new ParsePosition(0);
  return formatter.parse(dateStr,pos);
}

public static Date parseDate ( String dateStr ) { String formatString = "" ; if ( dateStr . length ( ) == 16 ) dateStr = dateStr . substring ( 0 , 14 ) ; if ( dateStr . length ( ) == 15 ) formatString = "yyyyMMdd'T'hhmmss" ; if ( dateStr . length ( ) == 8 ) formatString = "yyyyMMdd" ; SimpleDateFormat formatter = new SimpleDateFormat ( formatString ) ; ParsePosition pos = new ParsePosition ( 0 ) ; return formatter . parse ( dateStr , pos ) ; }
returns a date object from a string .
