Here you can find the source of toStringISO8601(Calendar cal)
public static String toStringISO8601(Calendar cal) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { public static String toStringISO8601(Date date, String timeZone) throws ParseException { Calendar cal = Calendar.getInstance(); cal.setTime(date);//from www .ja v a 2s.co m cal.setTimeZone(TimeZone.getTimeZone(timeZone)); return javax.xml.bind.DatatypeConverter.printDateTime(cal); } public static String toStringISO8601(Calendar cal) throws ParseException { return javax.xml.bind.DatatypeConverter.printDateTime(cal); } }