javaquartz-scheduler

How to get Quartz Trigger interval?


I am using Quartz for scheduling the java tasks. How to get the interval time for a specific trigger

for(Trigger trigger : getAllTrigersFromSchduler()) {
    trigger.getDescription(); // for description
    // Need trigger interval time
}

Solution

  • I stumble across this question and needed a solution as well, after reading thru the javadocs here's how you can read the defined interval. It's important to note that there are different types of triggers, assuming you're using the SimpleScheduleBuilder for creating triggers you can do the following:

    for(Trigger trigger : getAllTrigersFromSchduler()) {
        System.out.println(trigger.getDescription());   // for description
        // assuming a SimpleTrigger
        System.out.println(((SimpleTrigger)trigger).getRepeatInterval()));  // for interval in ms as long
    }
    

    regards