예제 #1
0
  @Override
  public int compareTo(Date that) {
    if (!isSpecific())
      throw new BACnetRuntimeException(
          "Comparisons can only be made between specific dates: " + this);
    if (!that.isSpecific())
      throw new BACnetRuntimeException(
          "Comparisons can only be made between specific dates: " + that);

    if (year == that.year) {
      if (month == that.month) return day - that.day;
      return month.ordinal() - that.month.ordinal();
    }
    return year - that.year;
  }
예제 #2
0
  /**
   * Matches this presumably wildcard date with a (that) necessarily specifically defined date to
   * determine if (true) the given date is one of this' defined dates or (false) not.
   *
   * @param that the specific date with which to compare.
   * @return
   */
  @Override
  public boolean matches(Date that) {
    if (!that.isSpecific())
      throw new BACnetRuntimeException("Dates for matching must be completely specified: " + that);

    if (!matchYear(that.year)) return false;

    if (!month.matches(that.month)) return false;

    if (!matchDay(that)) return false;

    if (!dayOfWeek.matches(that)) return false;

    return true;
  }