예제 #1
0
  public void testIsBusinessDay() {
    CalendarDate day = CalendarDate.from(2004, 1, 12); // it's a Monday
    for (int i = 0; i < 5; i++) {
      assertTrue("another working day", businessCalendar().isBusinessDay(day));
      day = day.nextDay();
    }
    assertFalse("finally, saturday arrived ...", businessCalendar().isBusinessDay(day));
    assertFalse("... then sunday", businessCalendar().isBusinessDay(day.nextDay()));

    CalendarDate newYearEve = CalendarDate.from(2004, 1, 1); // it's a
    assertFalse("hey, it's a holiday", businessCalendar().isBusinessDay(newYearEve));
  }
예제 #2
0
 public void testIsHoliday() {
   CalendarDate newYearEve = CalendarDate.from(2004, 1, 1); // it's a
   assertTrue("New Years Eve is a holiday.", businessCalendar().isHoliday(newYearEve));
   assertFalse(
       "The day after New Years Eve is not a holiday.",
       businessCalendar().isHoliday(newYearEve.nextDay()));
 }
예제 #3
0
  public void testIsWeekend() {
    CalendarDate saturday = CalendarDate.from(2004, 1, 10);
    assertTrue(businessCalendar().isWeekend(saturday));

    CalendarDate sunday = saturday.nextDay();
    assertTrue(businessCalendar().isWeekend(sunday));

    CalendarDate day = sunday;
    for (int i = 0; i < 5; i++) {
      day = day.nextDay();
      assertFalse("it's a midweek day", businessCalendar().isWeekend(day));
    }
    day = day.nextDay();
    assertTrue("finally, the weekend is here...", businessCalendar().isWeekend(day));

    CalendarDate newYearEve = CalendarDate.from(2004, 1, 1); // it's a
    assertFalse(
        "a holiday is not necessarily a weekend day", businessCalendar().isWeekend(newYearEve));
  }
예제 #4
0
  public void testNearestBusinessDay() {
    CalendarDate saturday = CalendarDate.from(2004, 1, 10);
    CalendarDate sunday = saturday.nextDay();
    CalendarDate monday = sunday.nextDay();
    assertEquals(monday, businessCalendar().nearestBusinessDay(saturday));
    assertEquals(monday, businessCalendar().nearestBusinessDay(sunday));
    assertEquals(monday, businessCalendar().nearestBusinessDay(monday));

    CalendarDate newYearEve = CalendarDate.from(2004, 1, 1); // it's a
    assertEquals(
        "it's a holiday & a thursday; wait till friday",
        newYearEve.nextDay(),
        businessCalendar().nearestBusinessDay(newYearEve));

    CalendarDate christmas = CalendarDate.from(2004, 12, 24); // it's a
    assertEquals(
        "it's a holiday & a friday; wait till monday",
        CalendarDate.from(2004, 12, 27),
        businessCalendar().nearestBusinessDay(christmas));
  }