Here you can find the source of dateToXmlDate(Date date)
public static XMLGregorianCalendar dateToXmlDate(Date date)
//package com.java2s; //License from project: Apache 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 dateToXmlDate(Date date) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date);/*from ww w . j a va2s . c o m*/ XMLGregorianCalendar gc = null; try { gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); } catch (Exception e) { e.printStackTrace(); } return gc; } }