@Override public Date parse(final String input) throws InvalidDateException { if(StringUtils.isBlank(input)) { throw new InvalidDateException(); } synchronized(format) { try { return format.parse(input); } catch(ParseException e) { throw new InvalidDateException(e.getMessage(), e); } } } }
private boolean check(final StringTokenizer st, final String token) throws InvalidDateException { try { if(st.nextToken().equals(token)) { return true; } else { throw new InvalidDateException(String.format("Missing [%s]", token)); } } catch(NoSuchElementException ex) { return false; } }
/** * Parse the given string in ISO 8601 format and build a Date object. * * @param input the date in ISO 8601 format * @return a Date instance * @throws InvalidDateException if the date is not valid */ public Date parse(final String input) throws InvalidDateException { if(StringUtils.isBlank(input)) { throw new InvalidDateException(); } return this.getCalendar(input).getTime(); } }
throw new InvalidDateException("No seconds specified"); throw new InvalidDateException("only Z, + or - allowed"); throw new InvalidDateException("Missing hour field"); throw new InvalidDateException("Missing minute field"); throw new InvalidDateException(String.format("[%s] is not an integer", ex.getMessage()), ex);