question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Special Character L for day of week behaves differently in Quartz

See original GitHub issue

According to Quartz using L for DoW is the last day (Saturday) in the week but cron-utils seems to return last Friday of the month. Am I doing something wrong or is this an issue?

    @Test
    public void lastDayOfTheWeek() throws Exception {
        Cron cron = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ))
                .parse("0 0 0 ? * L *");

        ZoneId utc = ZoneId.of("UTC");

        ZonedDateTime date = LocalDate.parse("2016-12-22").atStartOfDay(utc);

        ZonedDateTime cronUtilsNextTime = ExecutionTime.forCron(cron).nextExecution(date);// 2016-12-30T00:00:00Z

        org.quartz.CronExpression cronExpression = new org.quartz.CronExpression(cron.asString());
        cronExpression.setTimeZone(TimeZone.getTimeZone(utc));
        Date quartzNextTime = cronExpression.getNextValidTimeAfter(Date.from(date.toInstant()));// 2016-12-24T00:00:00Z

        assertEquals(quartzNextTime.toInstant(), cronUtilsNextTime.toInstant()); // false
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jmrozaneccommented, May 20, 2017

@laxgoalie392 Fixed! Kudos to @meincs for this!

0reactions
jmrozaneccommented, May 22, 2017

@laxgoalie392 @meincs version 6.0.0 was released with this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the CronTrigger | Quartz.NET
The W character can only be specified when the day-of-month is a single day, not a range or list of days. TIP. The...
Read more >
cron expression every 2 days not making sense for monday
Your cron schedule doesn't care about the day of the week. It is running simply on every uneven day of the month.
Read more >
Cron Expression Reference - Sybase Infocenter
The "L" character has a different meaning in each of the two fields. For example, "L" in the day-of-month field means the last...
Read more >
com.cronutils.parser.CronParser Java Examples
QUARTZ)); Cron cron = parser.parse(cronExpression); ExecutionTime ... Special Character L for day of week behaves differently in Quartz * @throws ...
Read more >
Cron Expressions
("last") This character has different meaning in day of month and day of week. For example, the value "L" in the day-of-month field...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found