Re: Timer Schedule TimerTask for same hour every day



On Jun 29, 7:08 pm, Arne Vajhøj <a...@xxxxxxxxxx> wrote:
Tomer wrote:
If the current time is 18:50 and ischeduleRepeating dailyTimerTask
to 18:52 then everything is file its being run at 18:52 daily however
if ischeduleit to 18:48 then its being run immediately (and i dont
want that) as i run the application :(
However i wanted it to be runeverydayat 18:48! how can i achieve
that?
Timertimer= newTimer();
Calendar date = Calendar.getInstance();
//Timerstarts yesterday (so that surely will run today when time
comes.
// date.setTimeInMillis(new Date().getTime() - 1000 * 60 * 60 * 24);
DateFormat sdf = new SimpleDateFormat("HH:mm");
Date dateToBackup = null;
try {
dateToBackup = sdf.parse("18:32");
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateToBackup);
date.set(Calendar.HOUR, calendar.get(Calendar.HOUR));
date.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE));
date.set(Calendar.SECOND, calendar.get(Calendar.SECOND));
date.set(Calendar.MILLISECOND, 0);

Why not just roll onedayforward ?



//Scheduleto runeveryday.
timer.schedule(
new TestTimerTask(),
date.getTime(),
1000 * 60 * 60 * 24
);
Thread.sleep(120000);
}

}

Arne

I didnt want to roll one day forward because i didnt want to have
special cases in my code like checking if the current time is later
than scheduled time and in that case roll one day forward, but now
that i see i have no choice, then i would need to check for that
special case and roll one day forward.

Thanks,

Tomer
.



Relevant Pages

  • calendar view tasks do not appear
    ... I have a calendar with tasks that roll up to specific ... dates set up on the Gantt chart. ... Although the multiple tasks are set up identically, ...
    (microsoft.public.project2000)
  • SharePoint calendar roll up and managing permissions and notificiations
    ... Sharepoint calendars for each of 5-7 PM offices and then use ... CorasWorks to roll up to a master calendar. ... I also want the owning Project Manager to be able to "boot" ...
    (microsoft.public.office.developer.outlook.vba)
  • SharePoint calendar roll up and managing permissions and notificiations
    ... Sharepoint calendars for each of 5-7 PM offices and then use ... CorasWorks to roll up to a master calendar. ... I also want the owning Project Manager to be able to "boot" ...
    (microsoft.public.exchange.admin)
  • Re: "I am calling you out"
    ... Now the instructor this happened to is an excellent athlete, ... Theyre just dumb id imagine. ... to be happy to roll with them, spar, whatever. ... sually though the good ones know theyre good and so they dont need to ...
    (rec.martial-arts)
  • Re: Make your own freezer paper
    ... yea but they sell it by the yard here for iirc, ... considering if they paid, for a large roll, full walmart ... i guess it helps those here that dont have a source for it. ...
    (rec.crafts.textiles.quilting)