dcsimg
Is there any java class to delay time
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   hendra_winata
Posted On:   Friday, May 18, 2001 01:40 AM

Well, right now i am creating a very simple program where i should get the system date and then i delay the program for maybe 3-4 hours .Every 3-4 hours has pass, i should get a new date again and compare it with the previous date. If both date still the same, nothing happened, if different, it will print out some text. So the problem is that i cant seems to find any java classes to cater the delay

Re: Is there any java class to delay time

Posted By:   Christopher_Schultz  
Posted On:   Friday, May 18, 2001 08:31 AM

Here's what you want to do:





Date previous = new Date(); // NOW!
while(true)
{
try {
Thread.currentThread().sleep(4*60*60*1000); // 4 Hours
} catch (InterruptedException ie)
{ /* ignore */ }

Date now = new Date();
if(previous.getDay() != now.getDay())
{
System.out.println("A day has gone by!");
}

previous = now;
}



HTH,

-chris
About | Sitemap | Contact