Quartz cron expression for cron triggers runs every Nth hour / day / week / month

I am developing an application that gives the user the ability to plan some actions. User provided inputs

  • N value
  • Option between hours / day / week / month
  • the date of the beginning
  • Start time

I cannot get cron expressions for each type of repeat interval ie Hour / Day / Week / Month so that the start time is calculated from the start date.

+1
source share
2 answers

Quartz documentation suggests using SimpleTrigger http://www.quartz-scheduler.org/docs/cookbook/BiDailyTrigger.html , an example for any other day:

Trigger trigger = new SimpleTrigger("trigger1", "group1");
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
// 24 hours * 60(minutes per hour) * 60(seconds per minute) * 1000(milliseconds per second)
trigger.setRepeatInterval(2L * 24L * 60L * 60L * 1000L);

, .

+2

Source: https://habr.com/ru/post/1780559/


All Articles