I've run into the oddest problem which really isn't making any sense.
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.
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.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
Source code for calcPatchNotesStartDate()