Here you can find the source of DateToXML(Date date)
public static XMLGregorianCalendar DateToXML(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { public static XMLGregorianCalendar DateToXML(Date date) { GregorianCalendar c = new GregorianCalendar(); c.setTime(date);//from w w w .j a va2s .c om XMLGregorianCalendar xmlDate = null; try { xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); } catch (Exception e) { // TODO: handle exception try { c.setTime(new Date()); xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); } catch (Exception e2) { // TODO: handle exception } System.out.println("Error al transformar fecha XML"); } return xmlDate; } }