@Test public void test3() { Calendar cal = Calendar.getInstance(); cal.set(i2011, 0, 8); Date start = cal.getTime(); cal.set(i2011, 0, 9); Date end = cal.getTime(); Assert.assertEquals(0, sut.getWeekdayCountBetweenDates(start, end)); }
public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; start = DateDayExtractor.getStartOfDay(startDate); cal = Calendar.getInstance(); cal.setTime(endDate); cal.add(Calendar.DATE, -1); end = DateDayExtractor.getStartOfDay(cal.getTime()); startMs = start.getTime(); endMs = end.getTime(); int weekdayCount = 0; while (startMs <= endMs) { cal.setTimeInMillis(startMs); if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { weekdayCount++; } startMs += MS_IN_DAY; } return weekdayCount; }
WeekdaysInDateRangeStrategy { public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; start = DateDayExtractor.getStartOfDay(startDate); cal = Calendar.getInstance(); cal.setTime(endDate); cal.add(Calendar.DATE, -1); end = DateDayExtractor.getStartOfDay(cal.getTime()); startMs = start.getTime(); endMs = end.getTime(); int weekdayCount = 0; while (startMs <= endMs) { cal.setTimeInMillis(startMs); if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { weekdayCount++; } startMs += MS_IN_DAY; } return weekdayCount; } }
WeekdaysInDateRangeStrategy { public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; start = DateDayExtractor.getStartOfDay(startDate); cal = Calendar.getInstance(); cal.setTime(endDate); cal.add(Calendar.DATE, -1); end = DateDayExtractor.getStartOfDay(cal.getTime()); startMs = start.getTime(); endMs = end.getTime(); int weekdayCount = 0; while (startMs <= endMs) { cal.setTimeInMillis(startMs); if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { weekdayCount++; } startMs += MS_IN_DAY; } return weekdayCount; }  }
WeekdaysInDateRangeStrategy { public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; start = DateDayExtractor.getStartOfDay(startDate); cal = Calendar.getInstance(); cal.setTime(endDate); cal.add(Calendar.DATE, -1); end = DateDayExtractor.getStartOfDay(cal.getTime()); startMs = start.getTime(); endMs = end.getTime(); int weekdayCount = 0; while (startMs <= endMs) { cal.setTimeInMillis(startMs); if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { weekdayCount++; } startMs += MS_IN_DAY; } return weekdayCount; }  int getWeekdayCountBetweenDates(final Date startDate, final Date endDate); }
WeekdaysInDateRangeStrategy { public int getWeekdayCountBetweenDates(final Date startDate, final Date endDate) { Calendar cal; Date start, end; long startMs, endMs; start = DateDayExtractor.getStartOfDay(startDate); cal = Calendar.getInstance(); cal.setTime(endDate); cal.add(Calendar.DATE, -1); end = DateDayExtractor.getStartOfDay(cal.getTime()); startMs = start.getTime(); endMs = end.getTime(); int weekdayCount = 0; while (startMs <= endMs) { cal.setTimeInMillis(startMs); if (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { weekdayCount++; } startMs += MS_IN_DAY; } return weekdayCount; }  int getWeekdayCountBetweenDates(final Date startDate, final Date endDate); static final long MS_IN_DAY; }