Java examples for XML:XML Calendar
Converts java.util.GregorianCalendar into javax.xml.datatype.XMLGregorianCalendar
//package com.java2s; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.util.GregorianCalendar; public class Main { /**/*from w w w .java 2s. c o m*/ * Converts java.util.GregorianCalendar into * javax.xml.datatype.XMLGregorianCalendar * * @param calendar * the calendar * @return instance of XMLGregorianCalendar */ public static XMLGregorianCalendar convert2XmlCalendar( GregorianCalendar calendar) { if (calendar == null) { return null; } try { return DatatypeFactory.newInstance().newXMLGregorianCalendar( calendar); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } } }