Here you can find the source of dateToXmlGregorianCalendar(Calendar date)
static XMLGregorianCalendar dateToXmlGregorianCalendar(Calendar date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { static XMLGregorianCalendar dateToXmlGregorianCalendar(Calendar date) { GregorianCalendar c = new GregorianCalendar(); c.setTime(date.getTime());//from w ww . ja v a 2s .c o m try { return DatatypeFactory.newInstance().newXMLGregorianCalendar(c); } catch (DatatypeConfigurationException e) { // Will never happen -- ignore return null; } } }