Here you can find the source of getXMLGregorianCalendar(Date date)
public static XMLGregorianCalendar getXMLGregorianCalendar(Date date)
//package com.java2s; import java.util.Date; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { private static DatatypeFactory dataTypeFactory = null; public static XMLGregorianCalendar getXMLGregorianCalendar(Date date) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date);//from w w w.j a v a2s.co m return getDatatypeFactory().newXMLGregorianCalendar(cal); } public static DatatypeFactory getDatatypeFactory() { if (dataTypeFactory == null) { try { dataTypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException ex) { } } return dataTypeFactory; } }