I am working on a scheduling project which executes multiple jobs at regular intervals. I am using a cron scheduling as in the example below. The jobs are getting executed successfully no problems. However for a requirement I want to calculate and persist the next run time of the Scheduled job in DB. Is there a solution to get next and previous fire times of jobs for the configuration below?
Example configuration:
import java.util.Date;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
@Component
@EnableScheduling
public class DemoServiceBasicUsageCron
{
@Scheduled(cron="1,3,30,32 * * * * ?")
public void demoServiceMethod()
{
System.out.println("Curent date time is - "+ new Date());
}
}