OlderThan extends LastModifiedFilter { @Override public boolean accept(File pathname) { try { Date filterDate = filterDate(); Date fileDate = new Date(pathname.lastModified()); return fileDate.before(filterDate); } catch (Exception e) { return false; } } OlderThan(String s); @Override boolean accept(File pathname);  }
@Test public void testOlderThanFutureSpec() throws Exception { OlderThan filter = new OlderThan("PT1H"); File file = writeFile(TempFileUtils.createTrackedFile(filter)); file.setLastModified(yesterday()); assertTrue(filter.accept(file)); }
@Test public void testBadDuration() throws Exception { OlderThan filter = new OlderThan("-PXXX"); File file = writeFile(TempFileUtils.createTrackedFile(filter)); file.setLastModified(yesterday()); assertFalse(filter.accept(file)); }
@Test public void testAbsolute() throws Exception { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, +1); OlderThan filter = new OlderThan("" + c.getTime().getTime()); File file = writeFile(TempFileUtils.createTrackedFile(filter)); assertTrue(filter.accept(file)); }