Solved

need java code to run a java program  daily at 4 oclock starting from tomorrow

Posted on 2009-07-01
5
333 Views
Last Modified: 2013-11-23
need a java code that runs a program which takes some files as input and generates an output file everyday at 4.clock starting from tomorow
import java.util.Calendar;

import java.util.Date;

import java.util.Timer;

import java.util.TimerTask;

 

public class ReadFileAndUpdateDb extends TimerTask {

 

  public void run() {

    //TODO  Code To  Read File And Update Db 

 }

 

}

 

class MainApplication {

 

  public static void main(String[] args) {

    Timer timer  new Timer();

    Calendar date = Calendar.getInstance();

    date.set(

      Calendar.DAY_OF_WEEK,

      Calendar.SUNDAY

    );

    date.set(Calendar.HOUR, 0);

    date.set(Calendar.MINUTE, 0);

    date.set(Calendar.SECOND, 0);

    date.set(Calendar.MILLISECOND, 0);

    // Schedule to run every Sunday in midnight

    timer.schedule(

      new ReadFileAndUpdateDb (),

      date.getTime(),

      1000 * 60 * 60 * 24 * 7

    );

  }

}

Open in new window

0
Comment
Question by:supportpro
  • 2
5 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 24752727
You can consider to put it  CRON or window scheduler . what is your OS?
0
 

Author Comment

by:supportpro
ID: 24753113
Windows  XP.But i prefer it to be in java code
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 24753319
schedule a task in windows xp

How to schedule ?
http://support.microsoft.com/kb/308569

and set the time as 4:00
0
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 500 total points
ID: 24753330
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 51
best (free) software to access postgres db (java) 1 32
Groovy:unable to resolve class error 2 65
rhino JavaScript import, load 25 66
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

948 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

20 Experts available now in Live!

Get 1:1 Help Now