Java XML Date Create toXmlGregorianCalendar(GregorianCalendar calendar)

Here you can find the source of toXmlGregorianCalendar(GregorianCalendar calendar)

Description

to Xml Gregorian Calendar

License

LGPL

Declaration

public static XMLGregorianCalendar toXmlGregorianCalendar(GregorianCalendar calendar) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import java.util.GregorianCalendar;

public class Main {
    public static XMLGregorianCalendar toXmlGregorianCalendar(GregorianCalendar calendar) {
        XMLGregorianCalendar xmlGregorianCalendar;
        DatatypeFactory datatypeFactory;
        try {/*from  w  w w.java 2s .  c om*/
            datatypeFactory = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new RuntimeException(e);
        }

        xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(calendar);

        return xmlGregorianCalendar;
    }
}

Related

  1. toXmlDateTime(GregorianCalendar cal)
  2. toXmlDateTimeUTC(Date date)
  3. toXMLGregorianCalendar(Date date)
  4. toXMLGregorianCalendar(Date date)
  5. toXMLGregorianCalendar(Date date, TimeZone timeZone, Locale locale)
  6. toXMLGregorianCalendar(long dateInMillis)
  7. toXMLGregorianCalendar(long timestamp)
  8. toXMLGregorianCalendar(String stringTypeDate)
  9. toXMLGregorianCalendar(Timestamp timestamp)