Java XML Date Create toXmlDate(Date date)

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

Description

to Xml Date

License

Open Source License

Declaration

public static XMLGregorianCalendar toXmlDate(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 {
    public static XMLGregorianCalendar toXmlDate(Date date) {
        try {//from  w  w  w  . j  ava2 s . co m
            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. toDate(XMLGregorianCalendar xmlCalendar)
  2. toDate(XMLGregorianCalendar xmlGregorianCalendar)
  3. toDateTime()
  4. toDateTime(Date date)
  5. toXMLCalendar(Date date)
  6. toXMLDate(Date date)
  7. toXmlDate(Date date)
  8. toXmlDate(DateTime cal)
  9. toXmlDate(GregorianCalendar date)