Solved

Checking for a certain date?

Posted on 2000-05-11
2
166 Views
Last Modified: 2010-04-01
How can I check for if a certain date have occured? The problem is that once a month I want certain tasks to be executed. Is there some class for this? I want to be able to set a certain date and when it occures I want an event to be raised.
0
Comment
Question by:sa9813
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
ID: 2800512
Java 1.3 (just released) has a class java.util.Timer. The purpose of this class is to allow scheduling a thread at a specified time. The task to be executed should be of type TimneTask (which implements Runnable and ads a few more methods).

The timer allows for scheduling at a particular time or in specified intervals. In you case I would suggest scheduling at a specified time and at the end of each monthly task schedulling the next one.

The alternative is to have thread (a Timer thread) which wakes up periodically and checks the date (or date and time). If they match a specified date (or date and time), it will start the task thread.
0
 
LVL 5

Expert Comment

by:msmolyak
ID: 2800522
To check whether the date occured you can use java.util.Calendar methods before(), after() or get().
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question