/** * Returns true if both date are in the same year, false otherwise. * @param actual the actual date. expected not be null * @param other the other date. expected not be null * @return true if both date are in the same year, false otherwise */ private static boolean areInSameYear(Date actual, Date other) { return yearOf(actual) == yearOf(other); }
/** * Verifies that the actual {@code Date} is strictly before the given year. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param year the year to compare actual year to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} year is after or equal to the given year. */ public void assertIsBeforeYear(AssertionInfo info, Date actual, int year) { assertNotNull(info, actual); if (yearOf(actual) < year) return; throw failures.failure(info, shouldBeBefore(actual, year)); }
/** * Verifies that the actual {@code Date} is strictly after the given year. * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @param year the year to compare actual year to * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} year is before or equal to the given year. */ public void assertIsAfterYear(AssertionInfo info, Date actual, int year) { assertNotNull(info, actual); if (yearOf(actual) > year) return; throw failures.failure(info, shouldBeAfter(actual, year)); }
/** * Verifies that the actual {@code Date} year is equal to the given year. * @param year the year to compare actual year to * @param info contains information about the assertion. * @param actual the "actual" {@code Date}. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if the actual {@code Date} year is not equal to the given year. */ public void assertIsWithinYear(AssertionInfo info, Date actual, int year) { assertNotNull(info, actual); if (yearOf(actual) == year) return; throw failures.failure(info, shouldBeWithin(actual, "year", year)); }