Here you can find the source of getXMLFormat(Calendar calendar)
private static String getXMLFormat(Calendar calendar) throws DatatypeConfigurationException
//package com.java2s; //License from project: Open Source License import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Locale; public class Main { private static String getXMLFormat(Calendar calendar) throws DatatypeConfigurationException { GregorianCalendar greg = new GregorianCalendar(Locale.US); greg.setTime(calendar.getTime()); greg.setTimeZone(calendar.getTimeZone()); XMLGregorianCalendar xmlCalendar = DatatypeFactory.newInstance() .newXMLGregorianCalendar(greg); return xmlCalendar.toXMLFormat(); }/* w ww. j a va 2 s . com*/ }