Solved

Checking for a certain date?

Posted on 2000-05-11
2
161 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
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
Comment Utility
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
Comment Utility
To check whether the date occured you can use java.util.Calendar methods before(), after() or get().
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now