Hi,
I have a program which is having 2 timers which gets triggered 2 timeswhen ever the time occurs and every day when ever i start a program. Now i have a situation where i start the program only once and every day it has to trigger 2 times with out starting the appication every day .
The below is the program which is triggering :
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class TimerTiggerEvent {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
//c.set(Calendar.HOUR,22);
c.set(Calendar.HOUR_OF_DAY,15);
c.set(Calendar.MINUTE,41);
c.set(Calendar.SECOND,00);
Date timeToRun=c.getTime();
System.out.println("date="+timeToRun);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
System.out.println("Hiiiii");
System.out.println(System.currentTimeMillis());
}
}, timeToRun);
c.set(Calendar.HOUR_OF_DAY,14);
c.set(Calendar.MINUTE,41);
c.set(Calendar.SECOND,00);
Date timeToRuns=c.getTime();
System.out.println("date="+timeToRun);
timer.schedule(new TimerTask() {
public void run() {
System.out.println("timeToRuns");
System.out.println(System.currentTimeMillis());
}
}, timeToRuns);
}
}
let me know what to do and what possibilities are there? any suggestions???