Here you can find the source of xmlGregorianCalendar()
public static XMLGregorianCalendar xmlGregorianCalendar() throws DatatypeConfigurationException
//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 { public static XMLGregorianCalendar xmlGregorianCalendar() throws DatatypeConfigurationException { GregorianCalendar cal = new GregorianCalendar(); return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); }// w w w . jav a 2s . c o m public static XMLGregorianCalendar xmlGregorianCalendar(Date date) throws DatatypeConfigurationException { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); } }