public static String toISO8601 ( Date pDate , TimeZone pTimeZone ) { SimpleDateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ssZ" ) ; dateFormat . setTimeZone ( pTimeZone ) ; String ret = dateFormat . format ( pDate ) ; ret = ret . replaceAll ( "\\+0000$" , "Z" ) ; return ret . replaceAll ( "(\\d\\d)$" , ":$1" ) ; }
Convert a given date to an ISO - 8601 compliant string representation for a given timezone