Пример #1
0
 public void testElapsedBusinessDays() {
   CalendarDate nov1 = CalendarDate.from(2004, 11, 1);
   CalendarDate nov30 = CalendarDate.from(2004, 11, 30);
   CalendarInterval interval = CalendarInterval.inclusive(nov1, nov30);
   assertEquals(Duration.days(30), interval.length());
   // 1 holiday (Thanksgiving on a Thursday) + 8 weekend days.
   assertEquals(21, businessCalendar().getElapsedBusinessDays(interval));
 }
Пример #2
0
 public void testBusinessDaysIterator() {
   CalendarDate start = CalendarDate.from(2004, 2, 5);
   CalendarDate end = CalendarDate.from(2004, 2, 8);
   CalendarInterval interval = CalendarInterval.inclusive(start, end);
   Iterator it = businessCalendar().businessDaysOnly(interval.daysIterator());
   assertTrue(it.hasNext());
   assertEquals(start, it.next());
   assertTrue(it.hasNext());
   assertEquals(CalendarDate.from(2004, 2, 6), it.next());
   assertFalse(it.hasNext());
 }
Пример #3
0
 public void testBusinessDayReverseIterator() {
   CalendarDate friday = CalendarDate.from(2006, 06, 16);
   CalendarDate nextTuesday = CalendarDate.from(2006, 06, 20);
   CalendarInterval interval = CalendarInterval.inclusive(friday, nextTuesday);
   Iterator it = businessCalendar().businessDaysOnly(interval.daysInReverseIterator());
   assertTrue(it.hasNext());
   assertEquals(nextTuesday, it.next());
   assertTrue(it.hasNext());
   CalendarDate nextMonday = CalendarDate.from(2006, 06, 19);
   assertEquals(nextMonday, it.next());
   assertTrue(it.hasNext());
   assertEquals(friday, it.next());
   assertFalse(it.hasNext());
 }