views:

39

answers:

2

Hi Guys

I want to send mail after specific time

Actually I want to send mail after 23 hour from the specific date

Now I am using java.util.TimerTask Thread to call that email function

Please help me..

Thanks

+1  A: 

Have you tried to use something like QuartZ Scheduler which will help manage scheduling and executing tasks: http://www.quartz-scheduler.org/

crafty
+1  A: 

The combination of Timer and TimerTask should suffice. The Timer class has a schedule() method. Just pass the TimerTask and a Date representing today plus 23 hours along it.

Timer timer = new Timer(true);
timer.schedule(new MailTask(), todayPlus23hours);

where the MailTask look like this:

public class MailTask extends TimerTask {
    public void run() {
        // Implement.
    }
}
BalusC
but my specific date changes on specific time so i can't add it as hardcoded
Tushar Ahirrao
Then just calculate it dynamically? You should really elaborate the **actual problem** in more detail. It now look more like that your problem is with calculating the date and not with executing the task.
BalusC