Here you can find the source of formatXsdDateTime(Date d)
public static String formatXsdDateTime(Date d)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static final String XSD_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; public static String formatXsdDateTime(Date d) { return formatDate(d, XSD_DATETIME_FORMAT); }/*from www .j a v a 2 s . c o m*/ public static String formatXsdDateTime(Date d, TimeZone tz) { return getDateFormat(XSD_DATETIME_FORMAT, tz).format(d); } public static String formatDate(Date date, String pattern) { if (date == null) { return null; } return getDateFormat(pattern).format(date); } public static DateFormat getDateFormat(String pattern) { return getDateFormat(pattern, TimeZone.getDefault()); } public static DateFormat getDateFormat(String pattern, TimeZone tz) { DateFormat result = new SimpleDateFormat(pattern); result.setTimeZone(tz); return result; } }