Index: src/java/org/quartz/CronExpression.java =================================================================== --- src/java/org/quartz/CronExpression.java (revision 714) +++ src/java/org/quartz/CronExpression.java (working copy) @@ -433,7 +433,7 @@ protected int storeExpressionVals(int pos, String s, int type) throws ParseException { - + int incr = 0; int i = skipWhiteSpace(pos, s); if (i >= s.length()) { @@ -953,8 +953,33 @@ } } + // if the end of the range is before the start, then we need to overflow into + // the next day, month etc. This is done by adding the maximum amount for that + // type, and using modulus max to determine the value being added + int max = 1; + if (stopAt < startAt) { + switch (type) { + case SECOND : max = 60; break; + case MINUTE : max = 60; break; + case HOUR : max = 24; break; + case MONTH : max = 12; break; + case DAY_OF_WEEK : max = 7; break; + case DAY_OF_MONTH : max = 31; break; + case YEAR : throw new IllegalArgumentException("Start year must be less than stop year"); + } + stopAt += max; + } + for (int i = startAt; i <= stopAt; i += incr) { - set.add(new Integer(i)); + // take the modulus to get the real value + int i2 = i % max; + + // 1-indexed ranges should not include 0, and should include their max + if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH) ) { + i2 = max; + } + + set.add(new Integer(i2)); } }