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 javax.xml.bind.DatatypeConverter; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { public static String formatISO8601(Date date) { if (date == null) { return null; }//w ww. jav a2s . c o m Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); cal.setTimeZone(TimeZone.getTimeZone("UTC")); return DatatypeConverter.printDateTime(cal); } }