List of utility methods to do XML Date
Date | convertDate(String date) convert Date return DatatypeConverter.parseDateTime(date).getTime();
|
Double | dateToDouble(Object value) date To Double Double ret = new Double(0.); if (value != null && value instanceof String) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); try { Calendar cal = DatatypeConverter.parseDateTime((String) value); long diff = cal.getTimeInMillis() + 2209161600000l; ret = diff / 86400000.; } catch (IllegalArgumentException e) { ... |
String | dateToString(Date date) date To String if (date == null) throw new IllegalArgumentException("date cannot be null"); Calendar cal = Calendar.getInstance(); cal.setTime(date); String result = DatatypeConverter.printDateTime(cal); if (result.length() < 16) return result; else ... |
String | dateToString(Date date) date To String Calendar c = Calendar.getInstance(ENCODING_TIME_ZONE, Locale.ENGLISH);
c.setTime(date);
return DatatypeConverter.printDateTime(c);
|
String | dateToXsdDateTime(Date date) Converts a Date object to the corresponding XSD DateTime String. Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(date);
return DatatypeConverter.printDateTime(calendar);
|
long | extractXsdDatetime(String string) Extracts the timestamp of a XsdDateTime string. return DatatypeConverter.parseDateTime(string).getTimeInMillis();
|
String | formatXmlDate(Calendar cal) Formats a calendar into an XML-formatted date only (without the time). if (cal == null) { return "null"; return DatatypeConverter.printDate(cal).substring(0, 10); |
String | getDateTimeRepresentation(Calendar date) Given a Calendar instance, returns its String representation according to XSD standards. return null != date ? DatatypeConverter.printDateTime(date) : ""; |
String | getDateTimeString(Date dateTime) get Date Time String Calendar cal = Calendar.getInstance(); if (dateTime != null) { cal.setTime(dateTime); return DatatypeConverter.printDateTime(cal); |
String | getXMLDate(final Date date) Converts Date into XML-Tag with type xsd:dateTime final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return DatatypeConverter.printDateTime(calendar); |