Java XML Date Create getXMLGregorianCalendar(Date date)

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

Description

get XML Gregorian Calendar

License

Open Source License

Declaration

public static XMLGregorianCalendar getXMLGregorianCalendar(Date date) 

Method Source Code


//package com.java2s;
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 {
    private static DatatypeFactory dataTypeFactory = null;

    public static XMLGregorianCalendar getXMLGregorianCalendar(Date date) {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(date);//from   w w  w.j a v  a2s.co m
        return getDatatypeFactory().newXMLGregorianCalendar(cal);
    }

    public static DatatypeFactory getDatatypeFactory() {
        if (dataTypeFactory == null) {
            try {
                dataTypeFactory = DatatypeFactory.newInstance();
            }

            catch (DatatypeConfigurationException ex) {
            }
        }
        return dataTypeFactory;
    }
}

Related

  1. getXMLDateStringFromDouble(double d)
  2. getXMLDateTime(Date date)
  3. getXMLFormat(Calendar calendar)
  4. getXmlGregCal(Date dt)
  5. getXMLGregorianCalendar()
  6. getXMLGregorianCalendar(Date date)
  7. getXmlGregorianCalendar(String unixTime)
  8. getXMLGregorianCalendar(TimeZone timeZone, Locale locale)
  9. getXMLGregorianCalendarFromDate(Date date)