I have the following code that works in that I can enter the hour, min and sec and it will wait until this time to run the code.
What I need is to be able to run this permanently and for it to run at 7am every morning (except saturday and sunday).
How can I alter this code to achieve the following, I also need to have this in its own thread due to other objects running their own code within the same package
import java.util.Timer; import java.util.TimerTask; import java.util.Calendar; import java.util.TimeZone; public class MyTimer { Timer timer; Calendar startTime; public MyTimer(int seconds) { startTime = Calendar.getInstance(TimeZone.getDefault()); startTime.set(Calendar.HOUR_OF_DAY, 20); startTime.set(Calendar.MINUTE, 56); startTime.set(Calendar.SECOND, 00); timer = new Timer(); timer.schedule(new RunTask(), startTime.getTime(), 1000 * 60 * 60 * 24); } class RunTask extends TimerTask { public void run() { System.out.println("It's Time"); timer.cancel(); //Terminate the timer thread } } public static void main(String args[]) { new MyTimer(5); System.out.println("Waiting"); } }