Here you can find the source of toXmlDateTimeUTC(Date date)
Parameter | Description |
---|---|
date | the date to convert |
public static XMLGregorianCalendar toXmlDateTimeUTC(Date date)
//package com.java2s; //License from project: Open Source License import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { private static DatatypeFactory factory = null; private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); /**//from w w w. j av a 2 s . com * Returns a XMLGregorianCalender (xml:dateTime) in UTC * * @param date the date to convert * @return dateTime in UTC e.g. 2012-03-14T12:34:56.789Z */ public static XMLGregorianCalendar toXmlDateTimeUTC(Date date) { if (date != null) { GregorianCalendar cal = new GregorianCalendar(UTC); cal.setTime(date); return factory.newXMLGregorianCalendar(cal); } else { return null; } } }