Here you can find the source of formatXMLDate(Date date, String pattern)
public static String formatXMLDate(Date date, String pattern)
//package com.java2s; //License from project: Apache License import java.util.*; import java.text.*; public class Main { public static String formatXMLDate(Date date) { StringBuffer sb = new StringBuffer(); addXMLHeader(sb);//from ww w . j a v a 2 s . com sb.append("<Date>"); sb.append(Long.toString(date.getTime())); sb.append("</Date>"); return (sb.toString()); } public static String formatXMLDate(Date date, String pattern) { StringBuffer sb = new StringBuffer(); addXMLHeader(sb); sb.append("<Date pattern=\""); sb.append(pattern); sb.append("\" >"); SimpleDateFormat fmt = new SimpleDateFormat(pattern); sb.append(fmt.format(date)); sb.append("</Date>"); return (sb.toString()); } public static void addXMLHeader(StringBuffer sb) { sb.append("<?xml version=\"1.0\"?>\n"); } }