@Test public void testIsPastOrCurrentDateWithYear() { DateTime dt = DateTime.now(); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2010-2011", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate((DateTime.now().getYear() - 1) + "-" + DateTime.now().getYear(), null, EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2011-2012", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2012-2013", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(DateTime.now().getYear() + "-" + (DateTime.now().getYear() + 1), null, EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate(dt.getYear()-1 + "-" + dt.getYear(), null, EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate(dt.getYear() + "-" + dt.getYear() + 1, null, EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2011-2012", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2012-2013", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2010-2009", DateTime.parse("2011-05-23", DateHelper.getDateTimeFormat()), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2008, 1, 31, 9, 0), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2009, 1, 1, 0, 0).minusMillis(1), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 1, 0, 0).minusMillis(1), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); Assert.assertFalse(EntityDateHelper.isPastOrCurrentDate("2010-2011", new DateTime(2009, 1, 31, 9, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 31, 9, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2007-2008", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2008-2009", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); Assert.assertTrue(EntityDateHelper.isPastOrCurrentDate("2009-2010", new DateTime(2010, 1, 1, 0, 0), EntityNames.GRADE)); }
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);  }