/** Converts a string containing a date or a date and a time to a DateTime. */ static DateTime toDateOrDateTime(String text) { if (text == null) { return null; } return DateTime.parseDateTimeChoice(text); }
/** Converts a string containing a date or a date and a time to a DateTime. */ static DateTime toDateOrDateTime(String text) { if (text == null) { return null; } return DateTime.parseDateTimeChoice(text); }
@Override public DateTime convertValue(String value, Class<? extends DateTime> datatype) throws ParseException { try { return DateTime.parseDateTimeChoice(value); } catch (NumberFormatException e) { throw new ParseException( CoreErrorDomain.ERR.invalidDatetime, e); } } }
@Override public DateTime convertValue(String value, Class<? extends DateTime> datatype) throws ParseException { try { return DateTime.parseDateTimeChoice(value); } catch (NumberFormatException e) { throw new ParseException( CoreErrorDomain.ERR.invalidDatetime, e); } } }
@Override public DateTime convertValue(String value, Class<? extends DateTime> datatype) throws ParseException { try { return DateTime.parseDateTimeChoice(value); } catch (NumberFormatException e) { throw new ParseException( CoreErrorDomain.ERR.invalidDatetime, e); } } }
/** * Gets the value of a {@link DateTime} attribute and remove it from the list. * * @param name attribute name or <code>null</code> for text content * @param required indicates attribute is required * @return the date-time value of this attribute, {@code null} by default * @exception ParseException if required is set and the attribute * is not defined, or if the date-time attribute cannot be parsed */ public DateTime consumeDateTime(String name, boolean required) throws ParseException { String value = consume(name, required); if (value == null) { return null; } try { return DateTime.parseDateTimeChoice(value); } catch (NumberFormatException e) { ParseException pe = new ParseException( CoreErrorDomain.ERR.invalidDatetime, e); pe.setInternalReason("Badly formatted datetime in attribute: " + name); throw pe; } }
/** * Gets the value of a {@link DateTime} attribute and remove it from the list. * * @param name attribute name or <code>null</code> for text content * @param required indicates attribute is required * @return the date-time value of this attribute, {@code null} by default * @exception ParseException if required is set and the attribute * is not defined, or if the date-time attribute cannot be parsed */ public DateTime consumeDateTime(String name, boolean required) throws ParseException { String value = consume(name, required); if (value == null) { return null; } try { return DateTime.parseDateTimeChoice(value); } catch (NumberFormatException e) { ParseException pe = new ParseException( CoreErrorDomain.ERR.invalidDatetime, e); pe.setInternalReason("Badly formatted datetime in attribute: " + name); throw pe; } }
/** * Gets the value of a {@link DateTime} attribute and remove it from the list. * * @param name attribute name or <code>null</code> for text content * @param required indicates attribute is required * @return the date-time value of this attribute, {@code null} by default * @exception ParseException if required is set and the attribute * is not defined, or if the date-time attribute cannot be parsed */ public DateTime consumeDateTime(String name, boolean required) throws ParseException { String value = consume(name, required); if (value == null) { return null; } try { return DateTime.parseDateTimeChoice(value); } catch (NumberFormatException e) { ParseException pe = new ParseException( CoreErrorDomain.ERR.invalidDatetime, e); pe.setInternalReason("Badly formatted datetime in attribute: " + name); throw pe; } }