Here you can find the source of toXMLGregorianCalendar(Date date)
public static XMLGregorianCalendar toXMLGregorianCalendar(Date date)
//package com.java2s; //License from project: Open Source License 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 { /**// w ww.j a v a 2 s . c o m * Converts Date to XMLGregorianCalendar */ public static XMLGregorianCalendar toXMLGregorianCalendar(Date date) { GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(date); XMLGregorianCalendar xmlCalendar = null; try { xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar); } catch (DatatypeConfigurationException ex) { // TODO } return xmlCalendar; } }