/** * Get the <code><a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a></code> contents * of the current {@link Element Element}, if it exists, is non-empty and has local name * <i>name</i>, as a {@link GregorianCalendar GregorianCalendar}. * * <p>Precision will be truncated to milliseconds. * * <p>The cursor will only be moved forward if the local element name matches <i>name</i>. * * @param name The local element name to test for. * @return The <code><a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a></code> * contents of the current {@link Element Element} as a {@link GregorianCalendar * GregorianCalendar}, if it exists, is non-empty and has local name <i>name</i>, null * otherwise. * @throws NoSuchElementException If the current element has local name <i>name</i> but has * non-text content. * @throws IOException If the current element has text-only content that cannot be parsed as * <code><a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a></code>. */ public GregorianCalendar getDateTimeConditional(String name) throws NoSuchElementException, IOException { String s = getStringConditional(name); return s != null ? ISODateTime.parseDateTime(s) : null; }
/** * Get the <code><a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a></code> contents * of the current {@link Element Element}, which must have local name <i>name</i>, as a {@link * GregorianCalendar GregorianCalendar}. * * <p>Precision will be truncated to milliseconds. * * @param name The local element name expected. * @return The <code><a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a></code> * contents of the current {@link Element Element} as a {@link GregorianCalendar * GregorianCalendar}. * @throws NoSuchElementException If the current element has non-text content, if it's local name * is not <i>name</i> or if there is no current element. * @throws IOException If the current element has text-only content that cannot be parsed as * <code><a href="http://www.w3.org/TR/xmlschema-2/#dateTime">dateTime</a></code>. */ public GregorianCalendar getDateTime(String name) throws NoSuchElementException, IOException { return ISODateTime.parseDateTime(getString(name)); }