@Test public void shouldGetNextApplicableDateAfterGivenDateBasedOnApplicableWeekDays() { DateTime oct1Sat2011 = new DateTime(2011, 10, 1, 0, 0); DateTime oct2Sun2011 = new DateTime(2011, 10, 2, 2, 0); DateTime oct3Mon2011 = new DateTime(2011, 10, 3, 0, 0); DateTime oct4Tue2011 = new DateTime(2011, 10, 4, 5, 0); DateTime oct6Thu2011 = new DateTime(2011, 10, 6, 3, 0); List<DayOfWeek> applicableDays = asList(Monday, Wednesday, DayOfWeek.Friday); assertThat(nextApplicableWeekDay(oct1Sat2011, applicableDays), is(oct1Sat2011.dayOfYear().addToCopy(2))); assertThat(nextApplicableWeekDay(oct2Sun2011, applicableDays), is(oct2Sun2011.dayOfYear().addToCopy(1))); assertThat(nextApplicableWeekDay(oct3Mon2011, applicableDays), is(oct3Mon2011.dayOfYear().addToCopy(2))); assertThat(nextApplicableWeekDay(oct4Tue2011, applicableDays), is(oct4Tue2011.dayOfYear().addToCopy(1))); assertThat(nextApplicableWeekDay(oct6Thu2011, applicableDays), is(oct6Thu2011.dayOfYear().addToCopy(1))); DateTime oct7Fri2011 = new DateTime(2011, 10, 7, 0, 1); DateTime oct8Sat2011 = new DateTime(2011, 10, 8, 0, 3); DateTime oct9Sun2011 = new DateTime(2011, 10, 9, 0, 4); DateTime oct10Mon2011 = new DateTime(2011, 10, 10, 5, 5); applicableDays = asList(DayOfWeek.Sunday, DayOfWeek.Saturday); assertThat(nextApplicableWeekDay(oct6Thu2011, applicableDays), is(oct6Thu2011.dayOfYear().addToCopy(2))); assertThat(nextApplicableWeekDay(oct7Fri2011, applicableDays), is(oct7Fri2011.dayOfYear().addToCopy(1))); assertThat(nextApplicableWeekDay(oct8Sat2011, applicableDays), is(oct8Sat2011.dayOfYear().addToCopy(1))); assertThat(nextApplicableWeekDay(oct9Sun2011, applicableDays), is(oct9Sun2011.dayOfYear().addToCopy(6))); assertThat(nextApplicableWeekDay(oct10Mon2011, applicableDays), is(oct10Mon2011.dayOfYear().addToCopy(5))); DateTime feb25Sat2012 = new DateTime(2012, 2, 25, 0, 5); applicableDays = asList(DayOfWeek.Saturday); DateTime actualMar3Sat2012 = feb25Sat2012.dayOfYear().addToCopy(7); assertNotSame(feb25Sat2012, actualMar3Sat2012); assertThat(nextApplicableWeekDay(feb25Sat2012, applicableDays), is(actualMar3Sat2012)); }
public static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays) { return nextApplicableWeekDayIncludingFromDate(fromDate.dayOfMonth().addToCopy(1), applicableDays); }
DateUtil { public static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays) { return nextApplicableWeekDayIncludingFromDate(fromDate.dayOfMonth().addToCopy(1), applicableDays); } }
DateUtil { public static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays) { return nextApplicableWeekDayIncludingFromDate(fromDate.dayOfMonth().addToCopy(1), applicableDays); } private  DateUtil(); }
DateUtil { public static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays) { return nextApplicableWeekDayIncludingFromDate(fromDate.dayOfMonth().addToCopy(1), applicableDays); } private  DateUtil(); static DateTime now(); static DateTime nowUTC(); static LocalDate today(); static LocalDate tomorrow(); static LocalDate newDate(int year, int month, int day); static DateTime newDateTime(LocalDate localDate, int hour, int minute, int second); static DateTime setTimeZone(DateTime dateTime); static DateTime setTimeZoneUTC(DateTime dateTime); static DateTime newDateTime(Date date); static DateTime newDateTime(LocalDate date); static Time time(DateTime dateTime); static LocalDate newDate(Date date); static LocalDate newDate(DateTime dateTime); static int daysPast(LocalDate localDate, DayOfWeek dayOfWeek); static boolean isOnOrBefore(DateTime firstDate, DateTime secondDate); static boolean isOnOrAfter(DateTime firstDate, DateTime secondDate); static boolean inRange(DateTime reference, DateTime start, DateTime end); static int daysToCalendarWeekEnd(LocalDate date, int calendarWeekStartDay); static DateTime newDateTime(LocalDate localDate, Time time); static DateTime newDateTime(int year, int month, int day, Time time); static DateTime newDateTime(int year, int month, int day); static DateTime newDateTime(int year, int month, int day, int hour, int minute, int second); static int getDifferenceOfDatesInYears(Date startDate); static DateTime endOfDay(Date dateTime); static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays); static DateTime nextApplicableWeekDayIncludingFromDate(DateTime fromDate, List<DayOfWeek> applicableDays); static List<DateTime> greaterThanOrEqualTo(final DateTime date, final List<DateTime> dates); static List<DateTime> lessThan(final DateTime date, final List<DateTime> dates); static List<DayOfWeek> daysStarting(DayOfWeek day, int numberOfDays); static List<DateTime> datesToDateTimes(List<Date> dates); static Date toDate(DateTime dateTime); static DateTime toDateTimeAtStartOfDay(LocalDate localDate); }
DateUtil { public static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays) { return nextApplicableWeekDayIncludingFromDate(fromDate.dayOfMonth().addToCopy(1), applicableDays); } private  DateUtil(); static DateTime now(); static DateTime nowUTC(); static LocalDate today(); static LocalDate tomorrow(); static LocalDate newDate(int year, int month, int day); static DateTime newDateTime(LocalDate localDate, int hour, int minute, int second); static DateTime setTimeZone(DateTime dateTime); static DateTime setTimeZoneUTC(DateTime dateTime); static DateTime newDateTime(Date date); static DateTime newDateTime(LocalDate date); static Time time(DateTime dateTime); static LocalDate newDate(Date date); static LocalDate newDate(DateTime dateTime); static int daysPast(LocalDate localDate, DayOfWeek dayOfWeek); static boolean isOnOrBefore(DateTime firstDate, DateTime secondDate); static boolean isOnOrAfter(DateTime firstDate, DateTime secondDate); static boolean inRange(DateTime reference, DateTime start, DateTime end); static int daysToCalendarWeekEnd(LocalDate date, int calendarWeekStartDay); static DateTime newDateTime(LocalDate localDate, Time time); static DateTime newDateTime(int year, int month, int day, Time time); static DateTime newDateTime(int year, int month, int day); static DateTime newDateTime(int year, int month, int day, int hour, int minute, int second); static int getDifferenceOfDatesInYears(Date startDate); static DateTime endOfDay(Date dateTime); static DateTime nextApplicableWeekDay(DateTime fromDate, List<DayOfWeek> applicableDays); static DateTime nextApplicableWeekDayIncludingFromDate(DateTime fromDate, List<DayOfWeek> applicableDays); static List<DateTime> greaterThanOrEqualTo(final DateTime date, final List<DateTime> dates); static List<DateTime> lessThan(final DateTime date, final List<DateTime> dates); static List<DayOfWeek> daysStarting(DayOfWeek day, int numberOfDays); static List<DateTime> datesToDateTimes(List<Date> dates); static Date toDate(DateTime dateTime); static DateTime toDateTimeAtStartOfDay(LocalDate localDate);  }