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

XMLGregorianCalendargetXMLGregorianCalendarFromDate(Date date)
get XML Gregorian Calendar From Date
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTime(date);
try {
    XMLGregorianCalendar xmlGrogerianCalendar = DatatypeFactory.newInstance()
            .newXMLGregorianCalendar(gregorianCalendar);
    return xmlGrogerianCalendar;
} catch (DatatypeConfigurationException e) {
    throw new RuntimeException(e);
...
XMLGregorianCalendargetXMLGregorianCalendarFromDate(Date date)
Converts a Date into a XMLGregorianCalendar
XMLGregorianCalendar retObj = null;
if (date != null) {
    GregorianCalendar gregCal = new GregorianCalendar();
    gregCal.setTime(date);
    retObj = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregCal);
return retObj;
XMLGregorianCalendargetXMLGregorianCalendarValue(Date date)
Gets an instance of XMLGregorianCalendar class initialized per the specified java.util.Date value.
GregorianCalendar gregorianCalendar = new GregorianCalendar();
if (date != null) {
    gregorianCalendar.setTime(date);
try {
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
} catch (DatatypeConfigurationException ex) {
    throw new IllegalStateException("Failed to create a new instance of DataTypeFactory.", ex);
...
XMLGregorianCalendargetXMLGregorianCalenderDate()
get XML Gregorian Calender Date
GregorianCalendar c = new GregorianCalendar();
c.setTime(Calendar.getInstance().getTime());
return DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
DatetoDate(final XMLGregorianCalendar xml)
Converts the given XML Gregorian calendar to a date.
if (xml != null) {
    return xml.toGregorianCalendar().getTime();
return null;
DatetoDate(long date)
to Date
return new Date(date);
DatetoDate(XMLGregorianCalendar cal)
Returns a Date date and time representation.
if (cal != null) {
    final Calendar c = Calendar.getInstance();
    c.set(Calendar.DATE, cal.getDay());
    c.set(Calendar.MONTH, cal.getMonth() - 1);
    c.set(Calendar.YEAR, cal.getYear());
    c.set(Calendar.DAY_OF_MONTH, cal.getDay());
    c.set(Calendar.HOUR_OF_DAY, cal.getHour());
    c.set(Calendar.MINUTE, cal.getMinute());
...
DatetoDate(XMLGregorianCalendar cal)
Liefert ein Date-Objekt fuer den Kalender.
if (cal == null)
    return null;
return cal.toGregorianCalendar().getTime();
DatetoDate(XMLGregorianCalendar date)
to Date
return date.toGregorianCalendar().getTime();
DatetoDate(XMLGregorianCalendar dateTime)
Convert an XML date/time to its java.util.Date equivalent.
return dateTime.toGregorianCalendar().getTime();