Quartz - schedule jobs every two Weeks on several Day of week and time

邮差的信 提交于 2019-11-27 23:15:43

I suggest, that you make a unit test based on your cron expression. With kudos to Van de Voorde Toni, you can base it on this code, and use it to verify that the "nextValidTimeAfter" matches your expectation:

import java.text.ParseException;
import java.util.Date;

import org.quartz.CronExpression;

public class CronTester {

    public static void main(String[] args) throws ParseException {
        final String expression = "* * 17 0 0/2 *,SUN,MON";
        final CronExpression cronExpression = new CronExpression(expression);

        final Date nextValidDate1 = cronExpression.getNextValidTimeAfter(new Date());
        final Date nextValidDate2 = cronExpression.getNextValidTimeAfter(nextValidDate1);

        System.out.println(nextValidDate1);
        System.out.println(nextValidDate2);

    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!