CalendarUtils { public static int weekDay(final Date date) { return fromDateToCalendar(date).get(DAY_OF_WEEK); } private  CalendarUtils(); static Calendar fromDateToCalendar(final Date date); static int weekDay(final Date date); static int month(final Date date); static int weekOfYear(final Date date); static int day(final Date date); static int dayOfYear(final Date date); static int year(final Date date); static boolean isLeapYear(final Date date); static boolean isAM(final Date date); static boolean isPM(final Date date); static int hour12(final Date date); static int hour24(final Date date); static int minute(final Date date); static int second(final Date date); static int millisecond(final Date date);  }
@Test public void testWeekDay() throws Exception { final Date mondayDate = date(2015, 12, 21); final Date fridayDate = date(2015, 12, 25); final Date nextMondayDate = date(2015, 12, 28); final int mondayWeekDay = CalendarUtils.weekDay(mondayDate); final int fridayWeekDay = CalendarUtils.weekDay(fridayDate); final int nextMondayWeekDay = CalendarUtils.weekDay(nextMondayDate); assertThat(mondayWeekDay, is(2)); assertThat(fridayWeekDay, is(6)); assertThat(nextMondayWeekDay, is(2)); }