Littera extends OkHttpSearchOnlyApi { static LocalDate parseCopyReturn(String str) { if (str == null) return null; DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN); final Matcher matcher = Pattern.compile("[0-9.-]{4,}").matcher(str); if (matcher.find()) { return fmt.parseLocalDate(matcher.group()); } else { return null; } }  @Override void init(Library library, HttpClientFactory httpClientFactory); @Override SearchRequestResult search(List<SearchQuery> query); @Override SearchRequestResult searchGetPage(int page); @Override DetailedItem getResultById(String id, String homebranch); @Override SearchRequestResult filterResults(Filter filter, Filter.Option option); @Override DetailedItem getResult(int position); @Override List<SearchField> parseSearchFields(); @Override String getShareUrl(String id, String title); @Override int getSupportFlags(); @Override Set<String> getSupportedLanguages(); @Override void setLanguage(String language);  }
@Test public void testParseCopyReturn() throws Exception { assert Objects.equals(Littera.parseCopyReturn("1 (voraussichtl. bis 31.07.2015)"), new LocalDate(2015, 7, 31)); }