• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

timer task not working with calendar date object

 
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.
 
Sheriff
Posts: 24635
56
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.
 
Sheriff
Posts: 21783
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!