/** * Returns true if this date exactly equals another date. To be considered equal, the {@code Day} ({@link #getDay get}) and {@code SecondsOfDay} ({@link #getSecondsOfDay get}) properties must be identical when converted to a common time standard. It is highly recommended that you use {@link #equalsEpsilon} or {@link #isIdentical} instead of this method. * @param other The date to compare to this instance. * @return {@code true} if {@code other} represents the same value as this instance; otherwise, {@code false}. */ public final boolean equalsType(@Nonnull JulianDate other) { return compareTo(other) == 0; }
/** * Determines if the interval contains a specified date. * @param date The date to test. * @return true if the interval contains the date, otherwise false. */ public final boolean contains(@Nonnull JulianDate date) { if (getIsEmpty()) { return false; } int startComparedToDate = m_start.compareTo(date); int dateComparedToStop = date.compareTo(m_stop); // return start < date && date < stop return startComparedToDate <= 0 && dateComparedToStop <= 0; }
/** * Returns true if {@code left} occurs before {@code right}. * @param left The date on the left side. * @param right The date on the right side. * @return {@code true} if the {@code left} is less than {@code right}, otherwise {@code false}. */ @CS2JInfo("This method implements the functionality of the overloaded operator: 'System.Boolean <(JulianDate,JulianDate)'") public static boolean lessThan(@Nonnull JulianDate left, @Nonnull JulianDate right) { return left.compareTo(right) < 0; }
/** * Returns true if {@code left} occurs after {@code right}. * @param left The date on the left side. * @param right The date on the right side. * @return {@code true} if the {@code left} is greater than {@code right}, otherwise {@code false}. */ @CS2JInfo("This method implements the functionality of the overloaded operator: 'System.Boolean >(JulianDate,JulianDate)'") public static boolean greaterThan(@Nonnull JulianDate left, @Nonnull JulianDate right) { return left.compareTo(right) > 0; }
/** * Returns true if {@code left} occurs after or at the same time as {@code right}. * @param left The date on the left side. * @param right The date on the right side. * @return {@code true} if the {@code left} is greater than or equal to {@code right}, otherwise {@code false}. */ @CS2JInfo("This method implements the functionality of the overloaded operator: 'System.Boolean >=(JulianDate,JulianDate)'") public static boolean greaterThanOrEqual(@Nonnull JulianDate left, @Nonnull JulianDate right) { return left.compareTo(right) >= 0; }
/** * Returns true if {@code left} occurs before or at the same time as {@code right}. * @param left The date on the left side. * @param right The date on the right side. * @return {@code true} if the {@code left} is less than or equal to {@code right}, otherwise {@code false}. */ @CS2JInfo("This method implements the functionality of the overloaded operator: 'System.Boolean <=(JulianDate,JulianDate)'") public static boolean lessThanOrEqual(@Nonnull JulianDate left, @Nonnull JulianDate right) { return left.compareTo(right) <= 0; }
public final int compare(@Nonnull LeapSecond x, @Nonnull LeapSecond y) { return x.getDate().compareTo(y.getDate()); } }
/** * Tests the check for EXACT equality and the check for equality within a specified tolerance. */ @Test public final void testEquality() { JulianDate first = new JulianDate(2451545, 0.2); JulianDate second = new JulianDate(2451545, 0.2); AssertHelper.assertEquals(first, second); Assert.assertTrue(first.equalsType(second)); Assert.assertTrue(second.equalsType(first)); Assert.assertEquals((int) 0, (int) first.compareTo(second)); Assert.assertEquals((int) 0, (int) second.compareTo(first)); AssertHelper.assertNotEqual(first, 5); first = new JulianDate(2451545, 0.00001); second = new JulianDate(2451544, 86399.99999); AssertHelper.assertNotEqual(first, second); Assert.assertFalse(first.equalsType(second)); Assert.assertFalse(second.equalsType(first)); AssertHelper.assertNotEqual(0, first.compareTo(second)); AssertHelper.assertNotEqual(0, second.compareTo(first)); Assert.assertTrue(first.equalsEpsilon(second, 1e-4)); Assert.assertTrue(second.equalsEpsilon(first, 1e-4)); }