/** * Creates a clone of this rule. * * @return a clone of this rule. * * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException { final RelativeDayOfWeekRule duplicate = (RelativeDayOfWeekRule) super.clone(); duplicate.subrule = (AnnualDateRule) duplicate.getSubrule().clone(); return duplicate; }
/** * Implements the method required by the Comparable interface. * * @param other the other object (usually another SerialDate). * * @return A negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. */ public int compareTo(final Object other) { return compare((SerialDate) other); }
/** * Factory method that returns an instance of some concrete subclass of * {@link SerialDate}. * * @param serial the serial number for the day (1 January 1900 = 2). * * @return a instance of SerialDate. */ public static SerialDate createInstance(final int serial) { return new SpreadsheetDate(serial); }
/** * Converts the date to a string. * * @return a string representation of the date. */ public String toString() { return getDayOfMonth() + "-" + SerialDate.monthCodeToString(getMonth()) + "-" + getYYYY(); }
/** * Returns true if this SerialDate represents the same date as the * specified SerialDate. * * @param other the date being compared to. * * @return <code>true</code> if this SerialDate represents the same date * as the specified SerialDate. */ public boolean isAfter(final SerialDate other) { return (this.serial > other.toSerial()); }
/** * Returns the actual number of days between two dates. * * @param start the start date. * @param end the end date. * * @return the number of days between the start date and the end date. */ public static int dayCountActual(final SerialDate start, final SerialDate end) { return end.compare(start); }
/** * Returns the date, given the year. * * @param yyyy the year. * * @return the date generated by this rule for the specified year (null permitted). */ public SerialDate getDate(final int yyyy) { return SerialDate.createInstance(this.dayOfMonth, this.month, yyyy); } }
/** * Default constructor - builds a rule for the Monday following 1 January. */ public RelativeDayOfWeekRule() { this(new DayAndMonthRule(), SerialDate.MONDAY, SerialDate.FOLLOWING); }
/** * Returns the latest date that falls on the specified day-of-the-week and * is BEFORE this date. * * @param targetDOW a code for the target day-of-the-week. * * @return the latest date that falls on the specified day-of-the-week and * is BEFORE this date. */ public SerialDate getPreviousDayOfWeek(final int targetDOW) { return getPreviousDayOfWeek(targetDOW, this); }
/** * Returns the nearest date that falls on the specified day-of-the-week. * * @param targetDOW a code for the target day-of-the-week. * * @return the nearest date that falls on the specified day-of-the-week. */ public SerialDate getNearestDayOfWeek(final int targetDOW) { return getNearestDayOfWeek(targetDOW, this); }
/** * Returns an array of month names. * * @return an array of month names. */ public static String[] getMonths() { return getMonths(false); }
/** * Converts the date to a string. * * @return a string representation of the date. */ public String toString() { return getDayOfMonth() + "-" + SerialDate.monthCodeToString(getMonth()) + "-" + getYYYY(); }
/** * Creates a clone of this rule. * * @return a clone of this rule. * * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException { final RelativeDayOfWeekRule duplicate = (RelativeDayOfWeekRule) super.clone(); duplicate.subrule = (AnnualDateRule) duplicate.getSubrule().clone(); return duplicate; }
/** * Returns true if this SerialDate represents the same date as the * specified SerialDate. * * @param other the date being compared to. * * @return <code>true</code> if this SerialDate represents the same date * as the specified SerialDate. */ public boolean isAfter(final SerialDate other) { return (this.serial > other.toSerial()); }
/** * Returns the actual number of days between two dates. * * @param start the start date. * @param end the end date. * * @return the number of days between the start date and the end date. */ public static int dayCountActual(final SerialDate start, final SerialDate end) { return end.compare(start); }
/** * Default constructor - builds a rule for the Monday following 1 January. */ public RelativeDayOfWeekRule() { this(new DayAndMonthRule(), SerialDate.MONDAY, SerialDate.FOLLOWING); }
/** * Creates a clone of this rule. * * @return a clone of this rule. * * @throws CloneNotSupportedException this should never happen. */ public Object clone() throws CloneNotSupportedException { final RelativeDayOfWeekRule duplicate = (RelativeDayOfWeekRule) super.clone(); duplicate.subrule = (AnnualDateRule) duplicate.getSubrule().clone(); return duplicate; }
/** * Returns the difference (in days) between this date and the specified * 'other' date. * * @param other the date being compared to. * * @return The difference (in days) between this date and the specified * 'other' date. */ public int compare(final SerialDate other) { return this.serial - other.toSerial(); }
/** * Returns true if this SerialDate represents the same date as the * specified SerialDate. * * @param other the date being compared to. * * @return <code>true</code> if this SerialDate represents the same date * as the specified SerialDate. */ public boolean isOnOrBefore(final SerialDate other) { return (this.serial <= other.toSerial()); }
/** * Returns true if this SerialDate represents the same date as the * specified SerialDate. * * @param other the date being compared to. * * @return <code>true</code> if this SerialDate represents the same date * as the specified SerialDate. */ public boolean isAfter(final SerialDate other) { return (this.serial > other.toSerial()); }