List of utility methods to do Date XML Format
String | formatDateToXML(Date dateTime) format Date To XML return formatDate(dateTime, XML_DATE_TIME_FORMAT);
|
String | formatToXMLDate(Date date) format To XML Date try { return new SimpleDateFormat("yyyyMMdd").format(date); } catch (Exception e) { return null; |
String | formatXml(Date date) Convert date to XML format return formatXml(date, null);
|
String | formatXMLDate(Date date, String pattern) format XML Date StringBuffer sb = new StringBuffer(); addXMLHeader(sb); sb.append("<Date pattern=\""); sb.append(pattern); sb.append("\" >"); SimpleDateFormat fmt = new SimpleDateFormat(pattern); sb.append(fmt.format(date)); sb.append("</Date>"); ... |
long | getTime(String xmlDateTime) Gets the time, in milliseconds, from an XML date time string as defined at http://www.w3.org/TR/xmlschema-2/#dateTime ParsePosition position = new ParsePosition(0); Date date = ISO_8601_BASE.parse(xmlDateTime, position); if (date == null) { throw new IllegalArgumentException("Invalid XML dateTime value: " + xmlDateTime + " (at position " + position.getErrorIndex() + ")"); Matcher matcher = ISO_8601_EXTRAS.matcher(xmlDateTime.substring(position.getIndex())); if (!matcher.matches()) { ... |
String | getXmlTime(Date date) get Xml Time return fixTimezone((new SimpleDateFormat(XML_TIME_FORMAT)).format(date)); |
Date | parse(String xmlDateTime) parse if (xmlDateTime.length() != 25) { throw new ParseException("Date not in expected xsd:datetime format", 0); StringBuilder sb = new StringBuilder(xmlDateTime); sb.deleteCharAt(22); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(XSD_DATETIME); return simpleDateFormat.parse(sb.toString()); |
String | toXMLDateTime(final Date date) Transform a Date object to a String formatted according to the specification of the dateTime datatype of XML schema.See section 3.2.7 of the XML Specification for details. if (date == null) return null; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXX"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); return formatter.format(date); |
Date | xml2Date(String xmlDate) xml Date return xmlDateFormat.parse(xmlDate);
|
String | XML2HL7(String XMLDate) XMLHL String out = ""; Date d; try { d = XMLDateFmt.parse(XMLDate); out = HL7DateFmt.format(d); } catch (Exception exp) { System.err.println(exp.getMessage()); return out; |