Here you can find the source of getXMLDate(Date dateTime)
Parameter | Description |
---|---|
dateTime | - |
public static XMLGregorianCalendar getXMLDate(Date dateTime)
//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; } }