Here you can find the source of toXmlDate(Date date)
Parameter | Description |
---|---|
date | the date to convert |
public static XMLGregorianCalendar toXmlDate(Date date)
//package com.java2s; //License from project: Open Source License import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { private static DatatypeFactory factory = null; /**/*from w w w. ja va 2 s . c o m*/ * Returns a XMLGregorianCalender (xml:date) in current timezone based upon the given date only * * @param date the date to convert * @return date e.g. 2012-03-14 */ public static XMLGregorianCalendar toXmlDate(Date date) { if (date != null) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); XMLGregorianCalendar xmlGregorianCalendar = factory.newXMLGregorianCalendar(cal); xmlGregorianCalendar.setHour(DatatypeConstants.FIELD_UNDEFINED); xmlGregorianCalendar.setMinute(DatatypeConstants.FIELD_UNDEFINED); xmlGregorianCalendar.setSecond(DatatypeConstants.FIELD_UNDEFINED); xmlGregorianCalendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED); xmlGregorianCalendar.setTimezone(DatatypeConstants.FIELD_UNDEFINED); return xmlGregorianCalendar; } else { return null; } } }