/** * Return the date for this rule, given the year. * * @param year the year. * * @return the date generated by the rule for the given year. */ public SerialDate getDate(final int year) { SerialDate result; if (this.count != SerialDate.LAST_WEEK_IN_MONTH) { // start at the beginning of the month result = SerialDate.createInstance(1, this.month, year); while (result.getDayOfWeek() != this.dayOfWeek) { result = SerialDate.addDays(1, result); } result = SerialDate.addDays(7 * (this.count - 1), result); } else { // start at the end of the month and work backwards... result = SerialDate.createInstance(1, this.month, year); result = result.getEndOfCurrentMonth(result); while (result.getDayOfWeek() != this.dayOfWeek) { result = SerialDate.addDays(-1, result); } } return result; }
/** * Return the date for this rule, given the year. * * @param year the year. * * @return the date generated by the rule for the given year. */ public SerialDate getDate(final int year) { SerialDate result; if (this.count != SerialDate.LAST_WEEK_IN_MONTH) { // start at the beginning of the month result = SerialDate.createInstance(1, this.month, year); while (result.getDayOfWeek() != this.dayOfWeek) { result = SerialDate.addDays(1, result); } result = SerialDate.addDays(7 * (this.count - 1), result); } else { // start at the end of the month and work backwards... result = SerialDate.createInstance(1, this.month, year); result = result.getEndOfCurrentMonth(result); while (result.getDayOfWeek() != this.dayOfWeek) { result = SerialDate.addDays(-1, result); } } return result; }
/** * Return the date for this rule, given the year. * * @param year the year. * * @return the date generated by the rule for the given year. */ public SerialDate getDate(final int year) { SerialDate result; if (this.count != SerialDate.LAST_WEEK_IN_MONTH) { // start at the beginning of the month result = SerialDate.createInstance(1, this.month, year); while (result.getDayOfWeek() != this.dayOfWeek) { result = SerialDate.addDays(1, result); } result = SerialDate.addDays(7 * (this.count - 1), result); } else { // start at the end of the month and work backwards... result = SerialDate.createInstance(1, this.month, year); result = result.getEndOfCurrentMonth(result); while (result.getDayOfWeek() != this.dayOfWeek) { result = SerialDate.addDays(-1, result); } } return result; }