How to write cron expression to trigger a function on 25th of every month at 9 A.M in the morning?
When I execute this code,
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
public class PayrollSchedulerImpl implements PayrollScheduler{
@Scheduled(cron="0 9 25 1 * ?")
public void calculateSalaryScheduled()
{
calculateSalary();
}
public void calculateSalary()
{
/* */
}
}
I get the error,
java.lang.StackOverflowError
sun.util.calendar.ZoneInfo.getOffsets(Unknown Source)
sun.util.calendar.ZoneInfo.getOffsets(Unknown Source)
java.util.GregorianCalendar.computeFields(Unknown Source)
java.util.GregorianCalendar.computeTime(Unknown Source)
java.util.Calendar.updateTime(Unknown Source)
java.util.Calendar.complete(Unknown Source)
java.util.Calendar.get(Unknown Source)
org.springframework.scheduling.support.CronSequenceGenerator.doNext(CronSequenceGenerator.java:130)
@Scheduled(cron="0 9 25 1 * ?")
This is on January 1st only, and the time is invalid, you'll want this instead:
@Scheduled(cron="0 0 9 25 * ?")
Reference: CronSequenceGenerator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With