Java XML Date Create getXMLDate(Date dateTime)

Here you can find the source of getXMLDate(Date dateTime)

Description

e.g.

License

Open Source License

Parameter

Parameter Description
dateTime -

Return

-

Declaration

public static XMLGregorianCalendar getXMLDate(Date dateTime) 

Method Source Code

//package com.java2s;

import java.util.Date;
import java.util.GregorianCalendar;

import java.util.TimeZone;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    /**/*from   ww  w.  jav  a  2 s.  com*/
     * e.g. "2012-09-11T10:10:10"
     * 
     * @param dateTime -
     * @return -
     */
    public static XMLGregorianCalendar getXMLDate(Date dateTime) {
        DatatypeFactory f = null;
        try {
            f = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new RuntimeException("convert to runtime exception", e);
        }
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTimeZone(TimeZone.getTimeZone("GMT"));
        cal.setTime(dateTime);
        XMLGregorianCalendar xmLGregorianCalendar = f.newXMLGregorianCalendar(cal);
        return xmLGregorianCalendar;
    }
}

Related

  1. dateToXMLGregorianCalendar(Date date)
  2. getXMLCalendar(String xsdDateTimeStr)
  3. getXMLCurrentTime()
  4. getXMLDate()
  5. getXMLDate(Date date)
  6. getXMLDate(final Calendar calendar)
  7. getXMLDateString()
  8. getXMLDateStringFromDouble(double d)
  9. getXMLDateTime(Date date)