private void setFirstTimeout() { Calendar currentCal = new GregorianCalendar(this.timezone); Date start = this.scheduleExpression.getStart(); if (start != null) { currentCal.setTime(start); } else { resetTimeToFirstValues(currentCal); } this.firstTimeout = getNextTimeout(currentCal, false); }
private Calendar advanceTillMonthHasDate(Calendar cal, Integer date) { resetTimeToFirstValues(cal); // make sure the month can handle the date while (monthHasDate(cal, date) == false) { if (cal.get(Calendar.YEAR) > Year.MAX_YEAR) { return null; } // this month can't handle the date, so advance month to next month // and get the next suitable matching month cal.add(Calendar.MONTH, 1); cal = this.computeNextMonth(cal); if (cal == null) { return null; } date = this.dayOfMonth.getFirstMatch(cal); if (date == null) { return null; } } cal.set(Calendar.DAY_OF_MONTH, date); return cal; }
private Calendar computeNextYear(Calendar nextCal) { Integer nextYear = this.year.getNextMatch(nextCal); if (nextYear == null || nextYear > Year.MAX_YEAR) { return null; } int currentYear = nextCal.get(Calendar.YEAR); // if the current year is a match, then nothing else to // do. Just return back the calendar if (currentYear == nextYear) { return nextCal; } // If the next year is lesser than the current year, then // we have no more timeouts for the calendar expression if (nextYear < currentYear) { return null; } // at this point we have chosen a year which is greater than the current // year. // set the chosen year nextCal.set(Calendar.YEAR, nextYear); // since we are moving to a different year (as compared to the current year), // we should reset all other calendar attribute expressions appropriately, to their first possible // values nextCal.set(Calendar.MONTH, this.month.getFirstMatch()); nextCal.set(Calendar.DAY_OF_MONTH, 1); resetTimeToFirstValues(nextCal); // recompute date nextCal = this.computeNextDate(nextCal); return nextCal; }
resetTimeToFirstValues(nextCal); resetTimeToFirstValues(nextCal); nextCal = this.computeNextMonth(nextCal); if (nextCal == null) {