Results 1 to 9 of 9

Thread: Scheduling

  1. #1
    Join Date
    Feb 2012
    Posts
    101

    Default Scheduling

    I would like to know how to set the cron expression with respect to GMT time.

    For eg. I have @Scheduled(cron = '0 0 0 * * *').should I add the time difference to the cron expression


    Thanks

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    That will use the default TimeZone (internally it calls TimeZone.getDefault()). Is that not GMT in your case?

  3. #3
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Well, if you are interested in the adjustment to current/default timezone then you don't need to do anything since CronTrigger will always use a Default TimeZone if one is not provided.
    However if not you'd need to specify it.

    We probably need to expose TimeZone attribute somehow, but for now all you need to do is specify a reference to CronTrigger instance. For example:
    Code:
    <bean id="cronTrigger" class="org.springframework.scheduling.suppor.CronTrigger">
        <constructor-arg value="your cron expression"/>
        <constructor-arg ref="ref to a TimeZone bean">
    </bean>

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Well, if you are interested in the adjustment to current/default timezone then you don't need to do anything since CronTrigger will always use a Default TimeZone if one is not provided.
    However if not you'd need to specify it.

    We probably need to expose TimeZone attribute somehow, but for now all you need to do is specify a reference to CronTrigger instance. For example:
    Code:
    <bean id="cronTrigger" class="org.springframework.scheduling.suppor.CronTrigger">
        <constructor-arg value="your cron expression"/>
        <constructor-arg ref="ref to a TimeZone bean">
    </bean>

  5. #5
    Join Date
    Feb 2012
    Posts
    101

    Default

    Yes Mark, its not GMT in my case, it is PST.

    Should a timezone bean class needs to be defined and how can cron trigger be specified in the scheduled annotation.

    Thanks

  6. #6
    Join Date
    Feb 2012
    Posts
    101

    Default

    Is it possible to give a timezone attribute in the scheduled annotation.


    Thanks

  7. #7
    Join Date
    Feb 2012
    Posts
    101

    Default

    Please clarify how to give the reference to the cronTrigger in the scheduled annotation

    Please help.

    Thanks

  8. #8
    Join Date
    Feb 2012
    Posts
    101

    Default

    Please tell me how to start the task at 12.00 am GMT time everyday,that can be specified in the cron expression in the scheduled annotation .

    Thanks a lot to help me with this.

  9. #9
    Join Date
    Sep 2011
    Posts
    28

    Default

    Quote Originally Posted by newbie_24 View Post
    Please tell me how to start the task at 12.00 am GMT time everyday,that can be specified in the cron expression in the scheduled annotation .

    Thanks a lot to help me with this.
    Following cron expression will let you run at 12:00AM:-


    <property name="cronExpression" value="0 0 12 * * ?" />

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •