@Test public void parseWithTimewords() { MatchedDate matchedDate = new MatchedDate("Wed Feb 24 2016 00:01 UTC+1201", null); MatchedDate parse = DateParser.parse(matchedDate, new HttpSource()); assertEquals("2016-02-24T00:01:00", DataUtils.formatInUTC(parse.getDate())); assertEquals("TIMEWORDS", parse.getPattern()); assertEquals("Wed Feb 24 2016 00:01 UTC+1201", parse.getValue()); }
private static MatchedDate parseWithTimewords(MatchedDate matchedText, HttpSource source) { Timewords timewords = new Timewords(); try { Date parse = timewords.parse(matchedText.getValue(), new Date(), source.getLanguage()); if (parse != null) { matchedText.setDate(new DateTime(parse)); matchedText.setPattern("TIMEWORDS"); } return matchedText; } catch (Exception e) { return matchedText; } }
DateParser { private static MatchedDate parseWithTimewords(MatchedDate matchedText, HttpSource source) { Timewords timewords = new Timewords(); try { Date parse = timewords.parse(matchedText.getValue(), new Date(), source.getLanguage()); if (parse != null) { matchedText.setDate(new DateTime(parse)); matchedText.setPattern("TIMEWORDS"); } return matchedText; } catch (Exception e) { return matchedText; } } }
DateParser { private static MatchedDate parseWithTimewords(MatchedDate matchedText, HttpSource source) { Timewords timewords = new Timewords(); try { Date parse = timewords.parse(matchedText.getValue(), new Date(), source.getLanguage()); if (parse != null) { matchedText.setDate(new DateTime(parse)); matchedText.setPattern("TIMEWORDS"); } return matchedText; } catch (Exception e) { return matchedText; } }  }
DateParser { private static MatchedDate parseWithTimewords(MatchedDate matchedText, HttpSource source) { Timewords timewords = new Timewords(); try { Date parse = timewords.parse(matchedText.getValue(), new Date(), source.getLanguage()); if (parse != null) { matchedText.setDate(new DateTime(parse)); matchedText.setPattern("TIMEWORDS"); } return matchedText; } catch (Exception e) { return matchedText; } }  static MatchedDate parse(MatchedDate matchedText, HttpSource source); static List<MatchedDate> extractFromMeta(Document document); static List<MatchedDate> extractFromProperties(Document document); }
DateParser { private static MatchedDate parseWithTimewords(MatchedDate matchedText, HttpSource source) { Timewords timewords = new Timewords(); try { Date parse = timewords.parse(matchedText.getValue(), new Date(), source.getLanguage()); if (parse != null) { matchedText.setDate(new DateTime(parse)); matchedText.setPattern("TIMEWORDS"); } return matchedText; } catch (Exception e) { return matchedText; } }  static MatchedDate parse(MatchedDate matchedText, HttpSource source); static List<MatchedDate> extractFromMeta(Document document); static List<MatchedDate> extractFromProperties(Document document);  }