DateUtil { public static boolean isSameDay(@NotNull final Date date1, @NotNull final Date date2) { return DateUtils.isSameDay(date1, date2); }  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 isSameDay() { Date date1 = new Date(106, 10, 1); Date date2 = new Date(106, 10, 1, 12, 23, 44); assertThat(DateUtil.isSameDay(date1, date2)).isTrue(); Date date3 = new Date(106, 10, 1); assertThat(DateUtil.isSameTime(date1, date3)).isTrue(); Date date5 = new Date(106, 10, 2); assertThat(DateUtil.isSameTime(date1, date5)).isFalse(); Date date4 = new Date(106, 10, 1, 12, 23, 43); assertThat(DateUtil.isBetween(date3, date1, date2)).isTrue(); assertThat(DateUtil.isBetween(date4, date1, date2)).isTrue(); try { DateUtil.isBetween(null, date1, date2); fail("should fail before"); } catch (Exception e) { } try { DateUtil.isBetween(date3, date2, date1); fail("should fail before"); } catch (Exception e) { } assertThat(DateUtil.isBetween(date5, date1, date2)).isFalse(); }