Here you can find the source of createXMLGregorianCalendar(Date currentDateTime)
public static XMLGregorianCalendar createXMLGregorianCalendar(Date currentDateTime)
//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.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { public static XMLGregorianCalendar createXMLGregorianCalendar(Date currentDateTime) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(currentDateTime); XMLGregorianCalendar createDate; try {//from w w w .j a va2 s. com createDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); createDate.setMillisecond(DatatypeConstants.FIELD_UNDEFINED); createDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } return createDate; } }