Java XML Date Create toXmlDate(GregorianCalendar date)

Here you can find the source of toXmlDate(GregorianCalendar date)

Description

to Xml Date

License

Open Source License

Declaration

public static XMLGregorianCalendar toXmlDate(GregorianCalendar 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 {
    public static XMLGregorianCalendar toXmlDate(GregorianCalendar date) {
        try {/*from  w ww .  j a va2  s  . co m*/
            return DatatypeFactory.newInstance().newXMLGregorianCalendar(date);
        } catch (DatatypeConfigurationException dtce) {
            throw new UnsupportedOperationException("Nemohu prevest " + "GregorianCalendar na XMLGregorianCalendar",
                    dtce);
        }
    }

    public static XMLGregorianCalendar toXmlDate(Date date) {
        try {
            GregorianCalendar c = new GregorianCalendar();
            c.setTime(date);
            return DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
        } catch (DatatypeConfigurationException dtce) {
            throw new UnsupportedOperationException("Nemohu prevest " + "GregorianCalendar na XMLGregorianCalendar",
                    dtce);
        }
    }
}

Related

  1. toXMLCalendar(Date date)
  2. toXmlDate(Date date)
  3. toXMLDate(Date date)
  4. toXmlDate(Date date)
  5. toXmlDate(DateTime cal)
  6. toXmlDateTime(GregorianCalendar cal)
  7. toXmlDateTimeUTC(Date date)
  8. toXMLGregorianCalendar(Date date)
  9. toXMLGregorianCalendar(Date date)