File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 62



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: 7056
    
  16

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?
Artlicles by Winston can be found here
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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
 
jQuery in Action, 2nd edition
 
subject: Java.util.Calendar
 
Similar Threads
Calendar.HOUR for another timezone
to compare time including AM and PM
Problem in updating Time
What fields does java.util.Date.equals compare?
How to compare (Hour) with actual new Date() ?