List of utility methods to do XML Date Create
XMLGregorianCalendar | toXmlDateTime(GregorianCalendar cal) Converts a GregorianCalendar to a XMLGregorianCalendar date time. return datatypeFactory.newXMLGregorianCalendar(cal);
|
XMLGregorianCalendar | toXmlDateTimeUTC(Date date) Returns a XMLGregorianCalender (xml:dateTime) in UTC if (date != null) { GregorianCalendar cal = new GregorianCalendar(UTC); cal.setTime(date); return factory.newXMLGregorianCalendar(cal); } else { return null; |
XMLGregorianCalendar | toXMLGregorianCalendar(Date date) to XML Gregorian Calendar GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(date); return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); |
XMLGregorianCalendar | toXMLGregorianCalendar(Date date) Converts Date to XMLGregorianCalendar GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(date); XMLGregorianCalendar xmlCalendar = null; try { xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar); } catch (DatatypeConfigurationException ex) { return xmlCalendar; ... |
XMLGregorianCalendar | toXMLGregorianCalendar(Date date, TimeZone timeZone, Locale locale) to XML Gregorian Calendar if (date == null) { return null; return toXMLGregorianCalendar(date.getTime(), timeZone, locale); |
XMLGregorianCalendar | toXmlGregorianCalendar(GregorianCalendar calendar) to Xml Gregorian Calendar XMLGregorianCalendar xmlGregorianCalendar; DatatypeFactory datatypeFactory; try { datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(calendar); ... |
XMLGregorianCalendar | toXMLGregorianCalendar(long dateInMillis) to XML Gregorian Calendar java.util.Date date = new java.util.Date(dateInMillis); return toXMLGregorianCalendar(date); |
XMLGregorianCalendar | toXMLGregorianCalendar(long timestamp) to XML Gregorian Calendar GregorianCalendar gc = new GregorianCalendar(GMT_TIME_ZONE); gc.setTimeInMillis(timestamp); try { return DatatypeFactory.newInstance().newXMLGregorianCalendar(gc); } catch (DatatypeConfigurationException e) { e.printStackTrace(); return null; |
XMLGregorianCalendar | toXMLGregorianCalendar(String stringTypeDate) to XML Gregorian Calendar String yyyy = stringTypeDate.substring(0, 4); String mm = stringTypeDate.substring(5, 7); String dd = stringTypeDate.substring(8, 10); String hh = stringTypeDate.substring(11, 13); String mi = stringTypeDate.substring(14, 16); String ss = stringTypeDate.substring(17, 19); int iyyyy = Integer.parseInt(yyyy); int imm = Integer.parseInt(mm); ... |
XMLGregorianCalendar | toXMLGregorianCalendar(Timestamp timestamp) to XML Gregorian Calendar GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(timestamp); XMLGregorianCalendar result = datatypeFactory.newXMLGregorianCalendar(calendar); result.setTimezone(DatatypeConstants.FIELD_UNDEFINED); result.setFractionalSecond(new BigDecimal(timestamp.getNanos()).divide(new BigDecimal(1000000000))); return result; |