
March 10th, 2013, 08:41 PM
|
|
Registered User
|
|
Join Date: Mar 2013
Posts: 3
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
|