TimerTask Scheduling upto the Minute

Hi All

Thanks for your replies to my ealier posts.

Now I have the code which can block out execution of tasks during particular hours of the day.

Is there a way I can specify upto the minute (when to block the task from running)

Like dont run the task 4:30AM - 6.15AM & 12:00 - 13:15 PM

Here is the code which can block based on hours:

import java.util.Timer;

import java.util.TimerTask;

publicclass Scheduler{

publicstaticvoid main(String[] args){

Timer timer =new Timer();

TimerTask task1 =new MyTask();

timer.schedule(task1, 1000);

Timer timer2 =new Timer();

TimerTask task2 =new MyTask2();

timer2.schedule(task2, 500);

}

}

//- MyTaskJava Code

import java.util.GregorianCalendar;

import java.util.TimerTask;

publicclass MyTaskextends TimerTask{

publicvoid run(){

System.err.println("Running My Task...");

int currentHour;

int currentMinute;

try

{

// would be a good idea to implement a general process flag

// to stop the process on any convenient moment

while(true)

{

// track the current time and evaluate if its not on the excluded interval

currentHour =new GregorianCalendar().get(GregorianCalendar.HOUR_OF_DAY);

currentMinute =new GregorianCalendar().get(GregorianCalendar.MINUTE);

System.out.println(currentHour);

if((currentHour >= 0 && currentHour < 11) || (currentHour > 14 && currentHour < 23))

{

// to implement process call

System.out.println("Its executed!");

}

// stops for 15 mins until next round

Thread.sleep(15000);

}

}

catch(Exception e)

{

// to implement exception logging

}

}

}

Please let me know.

Thanks

bib

[3484 byte] By [bib1a] at [2007-11-27 1:25:50]
# 1
where are my duke stars :) ?
Satish_Patila at 2007-7-12 0:19:20 > top of Java-index,Java Essentials,New To Java...
# 2
I had posted at http://forum.java.sun.com/thread.jspa?threadID=5161872&messageID=9617222#9617222where are my duke stars :) ?
Satish_Patila at 2007-7-12 0:19:20 > top of Java-index,Java Essentials,New To Java...
# 3
Awarded Duke to you and the other guru who helped me. I was just concentrating on getting my prob resolved.
bib1a at 2007-7-12 0:19:20 > top of Java-index,Java Essentials,New To Java...
# 4
If your issue is releavent to previous post, You can just reply to same thread. No need to create new thread
Satish_Patila at 2007-7-12 0:19:21 > top of Java-index,Java Essentials,New To Java...