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

DatetoDate(XMLGregorianCalendar xmlCalendar)
to Date
Date retObj = null;
if (xmlCalendar != null) {
    xmlCalendar.toGregorianCalendar().getTime();
return retObj;
DatetoDate(XMLGregorianCalendar xmlGregorianCalendar)
to Date
if (null == xmlGregorianCalendar) {
    return null;
GregorianCalendar gregorianCalendar = xmlGregorianCalendar.toGregorianCalendar();
return gregorianCalendar.getTime();
FunctiontoDateTime()
to Date Time
return xmlToJoda;
XMLGregorianCalendartoDateTime(Date date)
Convert a Java date to its XML date/time equivalent.
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
return datatypeFactory().newXMLGregorianCalendar(cal).normalize();
XMLGregorianCalendartoXMLCalendar(Date date)
to XML Calendar
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(date.getTime());
return dataFactory.newXMLGregorianCalendar(calendar);
XMLGregorianCalendartoXmlDate(Date date)
to Xml Date
try {
    GregorianCalendar c = new GregorianCalendar();
    c.setTime(date);
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
} catch (DatatypeConfigurationException dtce) {
    throw new UnsupportedOperationException("Nemohu prevest " + "GregorianCalendar na XMLGregorianCalendar",
            dtce);
XMLGregorianCalendartoXMLDate(Date date)
to XML Date
final XMLGregorianCalendar gregCalendar = dataTypeFactory.newXMLGregorianCalendar();
final Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(date);
gregCalendar.setYear(calendar.get(Calendar.YEAR));
gregCalendar.setMonth(calendar.get(Calendar.MONTH) + 1); 
gregCalendar.setDay(calendar.get(Calendar.DAY_OF_MONTH));
gregCalendar.setHour(calendar.get(Calendar.HOUR_OF_DAY));
gregCalendar.setMinute(calendar.get(Calendar.MINUTE));
...
XMLGregorianCalendartoXmlDate(Date date)
Returns a XMLGregorianCalender (xml:date) in current timezone based upon the given date only
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);
...
XMLGregorianCalendartoXmlDate(DateTime cal)
Converts a DateTime to XMLGregorianCalendar .
return datatypeFactory.newXMLGregorianCalendarDate(cal.getYear(), cal.getMonthOfYear(), cal.getDayOfMonth(),
        DatatypeConstants.FIELD_UNDEFINED);
XMLGregorianCalendartoXmlDate(GregorianCalendar date)
to Xml Date
try {
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(date);
} catch (DatatypeConfigurationException dtce) {
    throw new UnsupportedOperationException("Nemohu prevest " + "GregorianCalendar na XMLGregorianCalendar",
            dtce);