Java XML Date Create toXMLGregorianCalendar(Date date)

Here you can find the source of toXMLGregorianCalendar(Date date)

Description

Converts Date to XMLGregorianCalendar

License

Open Source License

Declaration

public static XMLGregorianCalendar toXMLGregorianCalendar(Date date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    /**// w ww.j a v a 2 s  .  c o m
     * Converts Date to XMLGregorianCalendar
     */
    public static XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
        GregorianCalendar gCalendar = new GregorianCalendar();
        gCalendar.setTime(date);
        XMLGregorianCalendar xmlCalendar = null;
        try {
            xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar);
        } catch (DatatypeConfigurationException ex) {
            // TODO
        }
        return xmlCalendar;
    }
}

Related

  1. toXmlDate(DateTime cal)
  2. toXmlDate(GregorianCalendar date)
  3. toXmlDateTime(GregorianCalendar cal)
  4. toXmlDateTimeUTC(Date date)
  5. toXMLGregorianCalendar(Date date)
  6. toXMLGregorianCalendar(Date date, TimeZone timeZone, Locale locale)
  7. toXmlGregorianCalendar(GregorianCalendar calendar)
  8. toXMLGregorianCalendar(long dateInMillis)
  9. toXMLGregorianCalendar(long timestamp)