Skip to content

Commit 077a866

Browse files
committed
Fix #426 with right Spring cron definition.
1 parent 1c01378 commit 077a866

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ private static CronDefinition quartz() {
317317
* <tr>
318318
* <td>Day of week</td>
319319
* <td>YES</td>
320-
* <td>1-7 or SUN-SAT</td>
320+
* <td>0-7 or SUN-SAT</td>
321321
* <td>* ? , - /</td>
322322
* </tr>
323323
* </table>
@@ -335,7 +335,7 @@ private static CronDefinition spring() {
335335
.withHours().withStrictRange().and()
336336
.withDayOfMonth().supportsQuestionMark().and()
337337
.withMonth().and()
338-
.withDayOfWeek().withValidRange(1, 7).withMondayDoWValue(2).supportsQuestionMark().and()
338+
.withDayOfWeek().withValidRange(0, 7).withMondayDoWValue(1).withIntMapping(7,0).supportsQuestionMark().and()
339339
.instance();
340340
}
341341

src/main/java/com/cronutils/model/time/generator/EveryFieldValueGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public int generateNextValue(final int reference) throws NoSuchValueException {
6565

6666
private int getNext(int reference, Every every) {
6767
final int offset = offset();
68+
6869
if (reference >= offset) {
6970
final int referenceWithoutOffset = reference - offset;
7071
final int period = every.getPeriod().getValue();

src/test/java/com/cronutils/mapper/CronMapperIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void testRangeOfTimeQuartzToCron4j() {
6464

6565
@Test
6666
public void testRangeOfTimeQuartzToSpring() {
67-
final String expected = "5 0 9-18 ? * 1-3";
67+
final String expected = "5 0 9-18 ? * 0-2";
6868
final String expression = "5 0 9-18 ? * 1-3 1984";
6969
assertEquals(expected, CronMapper.fromQuartzToSpring().map(quartzParser().parse(expression)).asString());
7070
}

0 commit comments

Comments
 (0)