@Override public Date parse(String source, ParsePosition pos) { try { return ISO8601Utils.parse(source, pos); } catch (ParseException e) { return null; } }
@Override public Date parse(String source) throws ParseException { return ISO8601Utils.parse(source, new ParsePosition(0)); }
@Override public Date parse(String source, ParsePosition pos) { try { return ISO8601Utils.parse(source, pos); } catch (ParseException e) { return null; } }
@Override public Date parse(String source, ParsePosition pos) { try { return ISO8601Utils.parse(source, pos); } catch (ParseException e) { return null; } }
@Override public Date parse(String source, ParsePosition pos) { try { return ISO8601Utils.parse(source, pos); } catch (ParseException e) { return null; } }
@Override public Date parse(String source, ParsePosition pos) { try { return ISO8601Utils.parse(source, pos); } catch (ParseException e) { return null; } }
@Override public Date parse(String source) throws ParseException { return ISO8601Utils.parse(source, new ParsePosition(0)); }
@Override public Date parse(String source) throws ParseException { return ISO8601Utils.parse(source, new ParsePosition(0)); }
@Override public Date parse(String source) throws ParseException { return ISO8601Utils.parse(source, new ParsePosition(0)); }
@Override public Date parse(String source) throws ParseException { return ISO8601Utils.parse(source, new ParsePosition(0)); }
public static Date parseIso8601Date(String iso8601Date) throws ParseException { return ISO8601Utils.parse(iso8601Date, new ParsePosition(0)); }
@Override public Date parse(String source, ParsePosition pos) { // index must be set to other than 0, I would swear this requirement is not there in // some version of jdk 6. pos.setIndex(source.length()); return ISO8601Utils.parse(source); }
@Override public Date parse(String source, ParsePosition pos) { // index must be set to other than 0, I would swear this requirement is not there in // some version of jdk 6. pos.setIndex(source.length()); return ISO8601Utils.parse(source); }
/** Parses an ISO 8601 date+time string into a Java Date object. */ public static Date parseTimestamp(@Nullable String string) { Date date = null; try { if (string != null) { date = ISO8601Utils.parse(string, new ParsePosition(0)); } } catch (ParseException e) { throw Throwables.propagate(e); } return date; }
/** Parses an ISO 8601 date+time string into a Java Date object. */ public static Date parseTimestamp(@Nullable String string) { Date date = null; try { if (string != null) { date = ISO8601Utils.parse(string, new ParsePosition(0)); } } catch (ParseException e) { throw Throwables.propagate(e); } return date; }
/** * Try to parse out a date from a JSON text node. * * @param node The JSON node to parse. * * @return A parsed date instance or {@code null} if the text is not an * ISO8601 formatted date and time string. */ private static Date dateValue(final JsonNode node) { String text = node.textValue().trim(); if (text.length() >= 19 && Character.isDigit(text.charAt(0)) && Character.isDigit(text.charAt(1)) && Character.isDigit(text.charAt(2)) && Character.isDigit(text.charAt(3)) && text.charAt(4) == '-') { try { return ISO8601Utils.parse(text, new ParsePosition(0)); } catch (ParseException e) { // This is not a date after all. } } return null; }
/** * Try to parse out a date from a JSON text node. * * @param node The JSON node to parse. * * @return A parsed date instance or {@code null} if the text is not an * ISO8601 formatted date and time string. */ private static Date dateValue(final JsonNode node) { String text = node.textValue().trim(); if (text.length() >= 19 && Character.isDigit(text.charAt(0)) && Character.isDigit(text.charAt(1)) && Character.isDigit(text.charAt(2)) && Character.isDigit(text.charAt(3)) && text.charAt(4) == '-') { try { return ISO8601Utils.parse(text, new ParsePosition(0)); } catch (ParseException e) { // This is not a date after all. } } return null; }
/** * Attempt to recognize a date and time or date only. * @param source The text for recognition. * @param pos Current position. * @return The date recognized from a string. * @throws ParseException Parse error. */ protected Date parseImpl(String source, ParsePosition pos) throws ParseException { if(StringUtils.isEmpty(source)) { return null; } if(source.length() - pos.getIndex() == PATTERN.length() || source.length() - pos.getIndex() + 1 == PATTERN.length()) { // Date only. return parseDateImpl(source, pos); } try { return ISO8601Utils.parse(source, pos); } catch (ParseException e) { // Date only. return parseDateImpl(source, pos); } }
/** * <p>parseDate.</p> * * @param value a {@link java.lang.String} object. * @param pos a {@link java.text.ParsePosition} object. * @return a {@link java.util.Date} object. */ public static Date parseDate(String value, ParsePosition pos) { Long timestamp = parseTimestamp(value); if (timestamp != null) { return new Date(timestamp); } if (value.contains(" ")) { value = value.replace(" ", "+"); } if (!(value.contains("-") || value.contains("+")) && !value.endsWith("Z")) { value += SYS_TZ; } try { return ISO8601Utils.parse(value, pos); } catch (ParseException e) { throw new ExtractorException(e); } }