Karthik sa
Karthik sa

Reputation: 49

How to specify PST time zone in @Scheduled annotation that should trigger every hour between 7AM PST to 6 PM PST?

My Java Web application has a Cron Job Scheduler which should trigger every hour starting from 7AM PST to 6PM PST. I am not getting how to specify PST time zone using zone parameter inside @Scheduled annotation. Kindly help

  @Component
  public class CronJobForFailedLoans {

      @Scheduled(cron ="0 0 7-18 ? * *")
     public void cronJobForFailedLoans()  {
    // Perform operations

 }  }

Upvotes: 2

Views: 2133

Answers (1)

Ryuzaki L
Ryuzaki L

Reputation: 40068

Your cron expression is valid just use Zone to specify the timezone, use online cron for validating and generating cron expression

@Scheduled(cron ="0 0 7-18 ? * *", zone="America/Los_Angeles")

Upvotes: 2

Related Questions