Well, here I want to schedule a task to be completed on the last day of every month at 10:10 AM. My cron expression
0 10 10 L * ?
Now the CronSequenceGenerator problem throws a NumberFormatException for the value L. This means Spring CronSequenceGenerator does not support this kind of expression. How to do this in any other way (workaround). I do not want to use quartz or support Spring in new releases.
Here is the full stacktrace:
Exception in thread "main" java.lang.NumberFormatException: For input string: "L" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.lang.Integer.valueOf(Integer.java:582) at org.springframework.scheduling.support.CronSequenceGenerator.getRange(CronSequenceGenerator.java:324) at org.springframework.scheduling.support.CronSequenceGenerator.setNumberHits(CronSequenceGenerator.java:297) at org.springframework.scheduling.support.CronSequenceGenerator.setDays(CronSequenceGenerator.java:275) at org.springframework.scheduling.support.CronSequenceGenerator.setDaysOfMonth(CronSequenceGenerator.java:266) at org.springframework.scheduling.support.CronSequenceGenerator.parse(CronSequenceGenerator.java:239) at org.springframework.scheduling.support.CronSequenceGenerator.<init>(CronSequenceGenerator.java:81) at org.springframework.scheduling.support.CronTrigger.<init>(CronTrigger.java:54) at org.springframework.scheduling.support.CronTrigger.<init>(CronTrigger.java:44) at com.hcdc.coedp.datantar.scheduler.SchedulerUtil.start(SchedulerUtil.java:75) at com.hcdc.coedp.datantar.scheduler.SchedulerUtil.changeTrigger(SchedulerUtil.java:106) at com.hcdc.coedp.datantar.scheduler.SchedulingService.scheduleTransfer(SchedulingService.java:70) at com.hcdc.coedp.datantar.scheduler.Scheduler.schedule(Scheduler.java:107) at main.Main.main(Main.java:47)
Update:
Below is my planning method
public String start(Task task, String cronExpression, String taskName) { CronTrigger trigger = new CronTrigger(cronExpression);
And on line 2, it throws a NumberFormatException when passing the specified cron expression.
java spring spring-mvc scheduled-tasks cronexpression
Dangling piyush
source share