@Test public void testIsPastOrCurrentDateWithDate() { Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2010-05-23", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2011-05-23", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate(null, DateTime.now(), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2012-11-11", DateTime.parse("2012-11-11T00:00:00"), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2012-11-11", DateTime.parse("2012-11-11T23:59:59.999"), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate(null, DateTime.now().minusMillis(1), EntityNames.DISCIPLINE_INCIDENT)); DateTimeFormatter datefrmt = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral('-').appendMonthOfYear(2).appendLiteral('-').appendDayOfMonth(2).toFormatter(); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(datefrmt.print(DateTime.now().plusDays(1)), DateTime.now(), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(null, DateTime.now().minusDays(1), EntityNames.DISCIPLINE_INCIDENT)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(null, DateTime.parse("2012-11-11"), EntityNames.DISCIPLINE_INCIDENT)); }
public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } }
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } } }
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } }  }
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } }  static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type); }
EntityDateHelper { public static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type) { DateTime finalUpToDate = (upToDate == null) ? DateTime.now() : upToDate; if (YEAR_BASED_ENTITIES.contains(type)) { return isBeforeOrEqualYear(entityDate, finalUpToDate.year().get()); } else { return isBeforeOrEqualDate(entityDate, finalUpToDate); } }  static boolean shouldExtract(Entity entity, DateTime upToDate); static String retrieveDate(Entity entity); static boolean isPastOrCurrentDate(String entityDate, DateTime upToDate, String type);  }