Here you can find the source of formatDateToXML(Date dateTime)
public static String formatDateToXML(Date dateTime)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String XML_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; public static String formatDateToXML(Date dateTime) { return formatDate(dateTime, XML_DATE_TIME_FORMAT); }// w w w .ja v a 2s. c om public static String formatDate(Date dateTime, String format) { if (dateTime != null) { SimpleDateFormat formatter = new SimpleDateFormat(format); String result = formatter.format(dateTime); return result; } else { return null; } } }