Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { public static XMLGregorianCalendar longToXMLGregorianCalendar(long time) throws DatatypeConfigurationException { if (time <= 0) { return null; } GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(time); XMLGregorianCalendar newXMLGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); return newXMLGregorianCalendar; } }