DateUtil { public static int getDayOfWeek(@NotNull final Date date) { int result = getWithMondayFirst(date, Calendar.DAY_OF_WEEK); return result == 1 ? 7 : result - 1; }  static boolean isSameDay(@NotNull final Date date1, @NotNull final Date date2); static boolean isSameTime(@NotNull final Date date1, @NotNull final Date date2); static boolean isBetween(@NotNull final Date date, @NotNull final Date start, @NotNull final Date end); static Date addMonths(@NotNull final Date date, int amount); static Date subMonths(@NotNull final Date date, int amount); static Date addWeeks(@NotNull final Date date, int amount); static Date subWeeks(@NotNull final Date date, int amount); static Date addDays(@NotNull final Date date, final int amount); static Date subDays(@NotNull final Date date, int amount); static Date addHours(@NotNull final Date date, int amount); static Date subHours(@NotNull final Date date, int amount); static Date addMinutes(@NotNull final Date date, int amount); static Date subMinutes(@NotNull final Date date, int amount); static Date addSeconds(@NotNull final Date date, int amount); static Date subSeconds(@NotNull final Date date, int amount); static Date setYears(@NotNull final Date date, int amount); static Date setMonths(@NotNull final Date date, int amount); static Date setDays(@NotNull final Date date, int amount); static Date setHours(@NotNull final Date date, int amount); static Date setMinutes(@NotNull final Date date, int amount); static Date setSeconds(@NotNull final Date date, int amount); static Date setMilliseconds(@NotNull final Date date, int amount); static int getDayOfWeek(@NotNull final Date date); static int getDayOfYear(@NotNull final Date date); static int getWeekOfMonth(@NotNull final Date date); static int getWeekOfYear(@NotNull final Date date); static Date beginOfYear(@NotNull final Date date); static Date endOfYear(@NotNull final Date date); static Date nextYear(@NotNull final Date date); static Date beginOfMonth(@NotNull final Date date); static Date endOfMonth(@NotNull final Date date); static Date nextMonth(@NotNull final Date date); static Date beginOfWeek(@NotNull final Date date); static Date endOfWeek(@NotNull final Date date); static Date nextWeek(@NotNull final Date date); static Date beginOfDate(@NotNull final Date date); static Date endOfDate(@NotNull final Date date); static Date nextDate(@NotNull final Date date); static Date beginOfHour(@NotNull final Date date); static Date endOfHour(@NotNull final Date date); static Date nextHour(@NotNull final Date date); static Date beginOfMinute(@NotNull final Date date); static Date endOfMinute(@NotNull final Date date); static Date nextMinute(@NotNull final Date date); static boolean isLeapYear(@NotNull final Date date); static boolean isLeapYear(int y); static int getMonthLength(@NotNull final Date date); static int getMonthLength(int year, int month); static final long MILLIS_PER_SECOND; static final long MILLIS_PER_MINUTE; static final long MILLIS_PER_HOUR; static final long MILLIS_PER_DAY; }
@Test public void getDayOfWeek() { Date date = new Date(117, 0, 9); assertThat(DateUtil.getDayOfWeek(date)).isEqualTo(1); Date date2 = new Date(117, 0, 15); assertThat(DateUtil.getDayOfWeek(date2)).isEqualTo(7); }