Gregorian Calendar Converter
public XMLGregorianCalendar DateToXmlGregorianCalendar(Date d) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(d); return new XMLGregorianCalendarImpl(gc); } public Date xmlGregorianCalendarToDate(XMLGregorianCalendar xgc) { return xgc.toGregorianCalendar().getTime(); }
The above code can be used to call the Gregorian Calender Converter which should be placed in the .util package.
document.setExpirationDate(XMLGregorianConverter.DateToXmlGregorianCalendar(new Date(1, 0, 0)));
Once the Converter is called this code can be used to set the actual time; it is worth noting that the base date is Jan, 1 1899. It may take some trial and error to get the dates correct.