List of utility methods to do XML Date to
Duration | getDurationFromCalendar(final XMLGregorianCalendar cal) getDurationFromCalendar. Duration dur; try { dur = DatatypeFactory.newInstance().newDurationDayTime(cal.getTimezone() * 60000); } catch (final DatatypeConfigurationException e) { return null; return dur; |
String | getGmtTimeFromXMLGregorianCalendar(XMLGregorianCalendar xgcal) Returns a time string of the form yyyy-MM-dd'T'HH:mm:ss'Z' from the specified XMLGregorianCalendar. if (xgcal == null) { return NOT_AVAILABLE; GregorianCalendar gcal = xgcal.toGregorianCalendar(TimeZone.getTimeZone("GMT"), null, null); Date date = gcal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); gcal = new GregorianCalendar(); gcal.setTime(date); ... |
String | getLocalTimeFromXMLGregorianCalendar(XMLGregorianCalendar xgcal) Returns a time string of the form given by Date.toString() from the specified XMLGregorianCalendar. if (xgcal == null) { return NOT_AVAILABLE; GregorianCalendar gcal = xgcal.toGregorianCalendar(TimeZone.getTimeZone("GMT"), null, null); Date date = gcal.getTime(); return date.toString(); |
long | getMilliseconds(XMLGregorianCalendar xmlCalendar) get Milliseconds return xmlCalendar.toGregorianCalendar().getTimeInMillis();
|
XMLGregorianCalendar | getNextMonthDate(GregorianCalendar calendar) get Next Month Date DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar aCal = (GregorianCalendar) calendar.clone();
aCal.add(Calendar.MONTH, 1);
return df.newXMLGregorianCalendar(aCal);
|
Timestamp | toTimestamp(XMLGregorianCalendar calendar) to Timestamp Timestamp result = new Timestamp(calendar.toGregorianCalendar().getTimeInMillis()); if (calendar.getFractionalSecond() != null) result.setNanos(calendar.getFractionalSecond().multiply(new BigDecimal(1000000000)).intValue()); return result; |
long | toTimestamp(XMLGregorianCalendar xgc) to Timestamp return xgc.toGregorianCalendar().getTimeInMillis();
|
Timestamp | toTimestamp(XMLGregorianCalendar xmlDate) to Timestamp if (xmlDate == null) return null; return new Timestamp(xmlDate.toGregorianCalendar().getTime().getTime()); |