public void testSetToFirstDayOfMonth() { // Start in middle of month { Date date = new Date(99, 5, 15); CalendarUtil.setToFirstDayOfMonth(date); assertTrue(CalendarUtil.isSameDate(new Date(99, 5, 1), date)); } // Start on first day of month { Date date = new Date(99, 5, 1); CalendarUtil.setToFirstDayOfMonth(date); assertTrue(CalendarUtil.isSameDate(new Date(99, 5, 1), date)); } }
public void testIsSameDate() { // Same date, same time { Date d0 = new Date(99, 5, 15, 3, 30, 5); Date d1 = new Date(99, 5, 15, 3, 30, 5); assertTrue(CalendarUtil.isSameDate(d0, d1)); } // Same date, different time { Date d0 = new Date(99, 5, 15, 3, 30, 5); Date d1 = new Date(99, 5, 15, 4, 20, 5); assertTrue(CalendarUtil.isSameDate(d0, d1)); } // Different date, same time { Date d0 = new Date(99, 5, 15, 3, 30, 5); Date d1 = new Date(99, 5, 18, 3, 30, 5); assertFalse(CalendarUtil.isSameDate(d0, d1)); } }