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 show the date on the beginning of each day Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "show the date on the beginning of each day" Watch "show the date on the beginning of each day" New topic
Author

show the date on the beginning of each day

aman shakya
Greenhorn

Joined: Oct 13, 2003
Posts: 4
I need to write some code that will show the current date at the
beginning of each day. The date should be shown exactly once when the
date changes from one day to the other.Please anyone help me.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

So you can have an endless loop, sleeping for a second (minute, whatever precision is needed), then get the date, compare it with previous, and react in some way, if it differs.
Where is the problem?


http://home.arcor.de/hirnstrom/bewerbung
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See if the javax.swing.Timer helps you. You can schedule something for a future time and it will sleep until the time and then do the thing. If this is your only scheduled event it might be overkill. You might start a thread that does something like this in a forever loop:

No guarantees anything there is spelled right or easy to do but hope it gives you some inspiration.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
don cline
Ranch Hand

Joined: Oct 10, 2003
Posts: 35
Assuming you have a process running continuously, you can start a thread that is responsible for showing the current date at the beginning of each day. You can then calculate the length of time before the beginning of the next day. You can then use Thread.sleep to sleep until it is time to show the display. That way, you don't use a lot of system resources waiting and checking.
Check out Calendar, Runnable (and Thread).
Good Luck
Don
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: show the date on the beginning of each day
 
Similar Threads
Java Calender
plz give me an idea...
How to retrieve day in MIDlet?
Date difference
add one day to current date