spring boot - Java task scheduler run daily from start to end date -


i've got spring boot application in java scheduled tasks need run @ midnight every day, 15th june 15th august

@scheduled(cron = "0 0 0 15-30 5 ?") // midnight every day 15th june until end of month public void sendreminderemailsjune() {     dostuff(); }  @scheduled(cron = "0 0 0 * 6 ?") // every day in july public void sendreminderemailsjuly() {     dostuff(); }  @scheduled(cron = "0 0 0 1-15 7 ?") // first day in august 15th august public void sendremindersemailsaugust() {     dostuff(); } 

is there better way don't need 3 separate @scheduled functions?

you repeat these annotations, if on spring 4 / jdk 8

@scheduled(cron = "0 0 12 * * ?")    @scheduled(cron = "0 0 18 * * ?")    public void sendreminderemails() {...} 

else, jdk 6+

@schedules({      @scheduled(cron = "0 0 12 * * ?"),       @scheduled(cron = "0 0 18 * * ?")})  public void sendreminderemails() {...}   

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -