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

StringgetXMLDateString()
get XML Date String
return getXMLDateString(0);
StringgetXMLDateStringFromDouble(double d)
Used for export (writes XML date strings).
if (d == Double.NEGATIVE_INFINITY) {
    return "-Infinity";
} else if (d == Double.POSITIVE_INFINITY) {
    return "Infinity";
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis((long) d);
return dateFactory.newXMLGregorianCalendar(gc).toXMLFormat().substring(0, 23);
...
XMLGregorianCalendargetXMLDateTime(Date date)
A new method, that contains the code previously present in the above method, that is, to create an XML GC Object with both the Date and time component.
GregorianCalendar gCal = new GregorianCalendar();
if (date != null) {
    gCal.setTime(date);
    XMLGregorianCalendar xgCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCal);
    return xgCal;
} else {
    return null;
StringgetXMLFormat(Calendar calendar)
get XML Format
GregorianCalendar greg = new GregorianCalendar(Locale.US);
greg.setTime(calendar.getTime());
greg.setTimeZone(calendar.getTimeZone());
XMLGregorianCalendar xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(greg);
return xmlCalendar.toXMLFormat();
XMLGregorianCalendargetXmlGregCal(Date dt)
get Xml Greg Cal
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(dt);
XMLGregorianCalendar xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
return xgc;
XMLGregorianCalendargetXMLGregorianCalendar()
get XML Gregorian Calendar
try {
    GregorianCalendar gcal = new GregorianCalendar();
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
} catch (DatatypeConfigurationException e1) {
    e1.printStackTrace();
    return null;
XMLGregorianCalendargetXMLGregorianCalendar(Date date)
get XML Gregorian Calendar
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
return getDatatypeFactory().newXMLGregorianCalendar(cal);
XMLGregorianCalendargetXMLGregorianCalendar(Date date)
get XML Gregorian Calendar
GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();
cal.setTime(date);
return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
XMLGregorianCalendargetXmlGregorianCalendar(String unixTime)
Turns a string representation of unix time into a XMLGregorianCalendar.
return getXmlGregorianCalendar(getDate(unixTime));
XMLGregorianCalendargetXMLGregorianCalendar(TimeZone timeZone, Locale locale)
get XML Gregorian Calendar
return DatatypeFactory.newInstance().newXMLGregorianCalendar(getGregorianCalendar(timeZone, locale));