scheduler java program

Hi everybody, This is my problem. I want to make a java program that run all time in server. But when in the midnight (00:00:00 AM) I want my program run some jobs like open file and update another file. My problem is how to make that shecduler program in java.

               
MeidiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nil_dibCommented:
Maybe there are smarter ways to do this ... but htat one works fine:


public class DateChecker extends Thread
{
    java.util.Date _date = null;
    public void run()
    {
        while(true)
        {
            _date = new java.util.Date();
            if( 0 == _date.getMinutes() && 0 == _date.getHours())
            {
                // its 0:00
                // do something
               
                System.out.println ( "it is 0:00 !" );
            }
            try
            {
                // check every 30 sec.
                this.sleep(30000);
            }
            catch (Exception e) {};          
            Thread.yield();
        }
    }


    public static void main(String[] args)
    {
        new DateChecker();
    }

    public DateChecker()
    {
        start();
    }
}

nil_dib
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jsridharCommented:
u can also use the javax.swing.Timer class.

js.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.