Here you can find the source of toXmlGregorianCalendar(GregorianCalendar calendar)
public static XMLGregorianCalendar toXmlGregorianCalendar(GregorianCalendar calendar)
//package com.java2s; //License from project: LGPL import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.util.GregorianCalendar; public class Main { public static XMLGregorianCalendar toXmlGregorianCalendar(GregorianCalendar calendar) { XMLGregorianCalendar xmlGregorianCalendar; DatatypeFactory datatypeFactory; try {/*from w w w.java 2s . c om*/ datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(calendar); return xmlGregorianCalendar; } }