Help coderanch get a
new server
by contributing to the fundraiser

pavan garina

Greenhorn
+ Follow
since Aug 09, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by pavan garina

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???
17 years ago