public static Calendar stringToCalendar(String s){
  Date date=null;
  try {
    date=TIME_FORMAT.parse(s);
  }
 catch (  ParseException e) {
    try {
      date=DATE_FORMAT.parse(s);
    }
 catch (    ParseException e1) {
      return null;
    }
  }
  if (date == null) {
    return null;
  }
  Calendar output=Calendar.getInstance();
  output.setTime(date);
  return output;
}

public static Calendar stringToCalendar ( String s ) { Date date = null ; try { date = TIME_FORMAT . parse ( s ) ; } catch ( ParseException e ) { try { date = DATE_FORMAT . parse ( s ) ; } catch ( ParseException e1 ) { return null ; } } if ( date == null ) { return null ; } Calendar output = Calendar . getInstance ( ) ; output . setTime ( date ) ; return output ; }
convert a string date / time into the according calendar . the format used is the formats defined as constants above .
