Java tutorial
import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { public static void main(final String[] args) throws Exception { GregorianCalendar gcal = (GregorianCalendar) GregorianCalendar.getInstance(); XMLGregorianCalendar xgcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal); System.out.println(xgcal); } }