public static String formatDate(Date date){
  String formatString="";
  Calendar cal=Calendar.getInstance();
  cal.setTime(date);
  if (cal.isSet(Calendar.MINUTE))   formatString="yyyyMMdd'T'hhmmss";
 else   formatString="yyyyMMdd";
  SimpleDateFormat formatter=new SimpleDateFormat(formatString);
  return formatter.format(date);
}

public static String formatDate ( Date date ) { String formatString = "" ; Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; if ( cal . isSet ( Calendar . MINUTE ) ) formatString = "yyyyMMdd'T'hhmmss" ; else formatString = "yyyyMMdd" ; SimpleDateFormat formatter = new SimpleDateFormat ( formatString ) ; return formatter . format ( date ) ; }
returns a string from a date object
