• Post Reply Bookmark Topic Watch Topic
  • New Topic

timer task not working with calendar date object  RSS feed

 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea is to have the timer task execute once every 12 hours ... specifically at 6am and 6pm. If I use a generic date object which is set to the current time ... it works. However when I use Calendar to create a new date object it runs constant non stop and I can't figure it out. Here is my code



The code is set to execute every 10 seconds right now for testing ... but even this code fires off every second. I'm not sure if it's just been a long day and I'm missing something ... but I can't figure it out. Any help would be great.
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API documentation for that method:

If an execution is delayed for any reason (such as garbage collection or other background activity), two or more executions will occur in rapid succession to "catch up."


And since you've told it you wanted it to start on March 1, it has over 3 weeks of catching up to do.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think Timer likes a start date in the past. Basically what Paul said.
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh oh oh ... I miss understood how it worked. I assumed that's what it was doing but just wanted to ask to be sure. Thanks guys.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!