Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Java.util.Calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java.util.Calendar" Watch "Java.util.Calendar" New topic
Author

Java.util.Calendar

hariharan jayaprakash
Ranch Hand

Joined: Sep 09, 2010
Posts: 63



I have tried to get the current time object, So i wanna to execute every minute to be noticed and then it should terminate the program for one minute.

Like "Page will be expired in 60 Seconds".. 59 58..... upto 0...
Then my code should terminate, How can i achieve this?...
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8244
    
  23

hariharan jayaprakash wrote:I have tried to get the current time object, So i wanna to execute every minute to be noticed and then it should terminate the program for one minute.

Like "Page will be expired in 60 Seconds".. 59 58..... upto 0...
Then my code should terminate, How can i achieve this?...

Quite tricky to do with 100% certainty, but you should probably start by looking at Thread.sleep(). The java.util.Timer class may also be of use.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

I'd go for java.util.Timer or a ScheduledExecutorService (creating using the Executors utility class).

Also:
hariharan jayaprakash wrote:

You should compare against the constants:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java.util.Calendar