Here you can find the source of formatIso8601(Date date)
public static String formatIso8601(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String formatIso8601 = "yyyy-MM-dd'T'HH:mm:ssZ"; public static String formatIso8601(Date date) { if (date == null) return ""; // Add a colon 2 chars before the end of the string // to make it a valid ISO-8601 date. String str = format(date, getIso8601DateFormat()); StringBuffer sb = new StringBuffer(); sb.append(str.substring(0, str.length() - 2)); sb.append(":"); sb.append(str.substring(str.length() - 2)); return sb.toString(); }/*from www. java 2s . com*/ /** * Returns a string the represents the passed-in date parsed * according to the passed-in format. Returns an empty string * if the date or the format is null. **/ public static String format(Date aDate, SimpleDateFormat aFormat) { if (aDate == null || aFormat == null) { return ""; } synchronized (aFormat) { return aFormat.format(aDate); } } public static SimpleDateFormat getIso8601DateFormat() { return new SimpleDateFormat(formatIso8601); } }