schedule job for given time
I have task which should be done reapited daily for given time.
I have one sc开发者_开发知识库heduler which scedule that task .but for e.g when I Started the scheduler at 2 pm then for next day schedule it 2 pm ,if started at 3 pm then schedule's it to next day for 3 pm.
But I want whenever schedule start but that task should be execute at given time. I am passing only the time in millisecond.
Is any way to pass the time in millisecond and that scheduler execute at given time only
reply if any one knows.
There is always Quartz Scheduler
to do this , Have a look at its quick start guide
, here is quick example
http://www.quartz-scheduler.org/docs/api/2.0.0/org/quartz/SimpleTrigger.html
If you need a simple solution or don't want to use a framework, take a look at java.util.Timer#scheduleAtFixedRate(TimerTask task, Date firstTime, long period):
Fixed-rate execution is appropriate for recurring activities that are sensitive to absolute time, such as ringing a chime every hour on the hour, or running scheduled maintenance every day at a particular time. It is also appropriate for recurring activities where the total time to perform a fixed number of executions is important, such as a countdown timer that ticks once every second for ten seconds. Finally, fixed-rate execution is appropriate for scheduling multiple repeating timer tasks that must remain synchronized with respect to one another.
精彩评论