Here you can find the source of xmlToDate(XMLGregorianCalendar calendar, DateFormat format)
public static String xmlToDate(XMLGregorianCalendar calendar, DateFormat format)
//package com.java2s; import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import javax.xml.datatype.XMLGregorianCalendar; public class Main { public final static DateFormat format_yyyyMMdd_HHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /**//from w w w . j ava2 s. c o m * if(null == calendar) return ""; if(null == format) default use format_yyyyMMdd_HHmmss */ public static String xmlToDate(XMLGregorianCalendar calendar, DateFormat format) { if (null == calendar) { return ""; } if (null == format) { format = format_yyyyMMdd_HHmmss; } return Format(format, calendar.toGregorianCalendar().getTime()); } public static String Format(DateFormat format, Timestamp time) { synchronized (format) { String t = ""; try { t = format.format(time); } catch (Exception e) { return t; } return t; } } public static String Format(DateFormat format, Date time) { synchronized (format) { String t = ""; try { t = format.format(time).replace("24:", "00:"); } catch (Exception e) { return t; } return t; } } public static String Format(DateFormat format, long time) { synchronized (format) { String t = ""; try { t = format.format(time); } catch (Exception e) { return t; } return t; } } }