question: 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 ) ; }
target:  Returns a String from a Date object 