This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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: 7892
    
  21

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: 19697
    
  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
 
GeeCON Prague 2014
 
subject: Java.util.Calendar