Code example for XMLGregorianCalendar

Methods: toGregorianCalendar

public class ConversionUtils { 
	private static Log logger = LogFactory.getLog(ConversionUtils.class);
	public static Date xmlGregorianCalendarToDate(XMLGregorianCalendar calendar) {
		return calendar.toGregorianCalendar().getTime();
	public static XMLGregorianCalendar dateToXmlGregorianCalendar(Date date) {
		GregorianCalendar gc = new GregorianCalendar();
		XMLGregorianCalendar xgc = null;
		try { 
			xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
		} catch (DatatypeConfigurationException dce) {
			logger.error("Error converting date to XmlGregorianCalendar: " + dce.getMessage());
		return xgc;
Connect your IDE to all the code out there  Get Codota for Java