Java Utililty Methods XML Date Create

List of utility methods to do XML Date Create

Description

The list of methods to do XML Date Create are organized into topic(s).

Method

XMLGregorianCalendardateToXmlGregorianCalendar(Calendar date)
date To Xml Gregorian Calendar
GregorianCalendar c = new GregorianCalendar();
c.setTime(date.getTime());
try {
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
} catch (DatatypeConfigurationException e) {
    return null;
XMLGregorianCalendardateToXmlGregorianCalendar(Date d)
date To Xml Gregorian Calendar
if (d == null) {
    return null;
GregorianCalendar gregory = new GregorianCalendar();
gregory.setTime(d);
XMLGregorianCalendar returnValue;
returnValue = datatypeFactory.newXMLGregorianCalendar(gregory);
return returnValue;
...
XMLGregorianCalendardateToXMLGregorianCalendar(Date date)
date To XML Gregorian Calendar
if (date == null) {
    return null;
GregorianCalendar gCalendar = new GregorianCalendar();
gCalendar.setTime(date);
return DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar);
XMLGregorianCalendardateToXMLGregorianCalendar(Date date)
date To XML Gregorian Calendar
if (date == null)
    return null;
return DatatypeFactory.newInstance().newXMLGregorianCalendar(dateToGregorianCalendar(date));
XMLGregorianCalendargetXMLCalendar(String xsdDateTimeStr)
get XML Calendar
return getDatatypeFactory().newXMLGregorianCalendar(xsdDateTimeStr);
XMLGregorianCalendargetXMLCurrentTime()
get XML Current Time
GregorianCalendar gcal = new GregorianCalendar();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
return xcal;
XMLGregorianCalendargetXMLDate()
get XML Date
GregorianCalendar cal = new GregorianCalendar();
XMLGregorianCalendar sample;
XMLGregorianCalendar result;
try {
    sample = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    result = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    result.clear();
    result.setMonth(sample.getMonth());
...
XMLGregorianCalendargetXMLDate(Date date)
Gets the XML Gregorian calendar from date.
DatatypeFactory dataTypeFactory;
try {
    dataTypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
    throw new RuntimeException(e);
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(date.getTime());
...
XMLGregorianCalendargetXMLDate(Date dateTime)
e.g.
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"));
...
XMLGregorianCalendargetXMLDate(final Calendar calendar)
get XML Date
GregorianCalendar c;
if (calendar instanceof GregorianCalendar) {
    c = (GregorianCalendar) calendar;
} else {
    c = new GregorianCalendar();
    c.setTimeZone(UTC);
    c.setTime(calendar.getTime());
try {
    XMLGregorianCalendar ret = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    ret.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
    return ret;
} catch (DatatypeConfigurationException e) {
    return null;