Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 10th, 2013, 08:41 PM
JamesHenderson JamesHenderson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 3 JamesHenderson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 2 sec
Reputation Power: 0
Timer.scheduleAtFixedRate() is scheduling itself to run on the wrong day

I've run into the oddest problem which really isn't making any sense.

Code:
Timer timer = new Timer();

//7 days
long patchNotesSleep = 7 * 24 * 60 * 60 * 1000;

TimerTask task = new TimerTask() {public void run() {}};

//Schedule at 14:55 on the next Thursday
Date nextDate = calcPatchNotesStartDate();

timer.scheduleAtFixedRate(task, nextDate, patchNotesSleep);

System.out.println("Should start at " + nextDate);
System.out.println("Patch Notes scheduled to check at " + new Date(task.scheduledExecutionTime()));


What I'm expecting is for the two print statements to return the same dates. What I'm actually getting is this.

Quote:
Should start at Thu Mar 14 14:55:00 EDT 2013
Patch Notes scheduled to check at Thu Mar 07 13:55:00 EST 2013


I've tried throwing breakpoints and comparing the actual date objects, just in case something weird was going on with the print. They are different dates.

Source code for calcPatchNotesStartDate()

Edit: Some user/board setting is keeping me from clicking on the above link. Here's the url, just in case.
http://pastebin.com/p1d0aV6b

Reply With Quote
  #2  
Old March 11th, 2013, 11:29 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 51 m 13 sec
Reputation Power: 345

Reply With Quote
  #3  
Old March 11th, 2013, 01:28 PM
JamesHenderson JamesHenderson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 3 JamesHenderson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 2 sec
Reputation Power: 0
Sorry, it's a perplexing problem so I thought I would ask in different forums and these two seemed like the ones with a decent response rate. Are these two websites linked in some way?

Reply With Quote
  #4  
Old March 11th, 2013, 01:33 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 51 m 13 sec
Reputation Power: 345
The volunteers that work these forums consider it a courtesy if posters will post links to all the sites where a question is asked to keep them from wasting time answering a question that has already been answered.

Your post doesn't say which date/time is the unexpected one.
Why do you expect them to be the same? Is there some doc that says that?

Reply With Quote
  #5  
Old March 11th, 2013, 01:39 PM
JamesHenderson JamesHenderson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 3 JamesHenderson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 2 sec
Reputation Power: 0
Quote:
Originally Posted by NormR
The volunteers that work these forums consider it a courtesy if posters will post links to all the sites where a question is asked to keep them from wasting time answering a question that has already been answered.

Your post doesn't say which date/time is the unexpected one.
Why do you expect them to be the same? Is there some doc that says that?


That's a fair reason. Sorry about the duplication. Looks like we're going to have the exact issue you were trying to avoid, as I have posted a reply (awaiting moderation) at the other site.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Timer.scheduleAtFixedRate() is scheduling itself to run on the wrong day

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap