problem with Scheduling a Timer Task to Run Repeatedly every month

here is a code I used in making a scheduling a timer task to run repeatedly...

int delay = 5000;// delay for 5 sec.

int period = 1000;// repeat every sec.

Timer timer =new Timer();

timer.scheduleAtFixedRate(new TimerTask(){

publicvoid run(){

// Task here ...

}

}, delay, period);

but when I change theint period to run every month

int period = 1000*3600*24*30

I encounter this

Exception in thread"AWT-EventQueue-0" java.lang.IllegalArgumentException: Non-positive period.

I changeint period value of 1000 to 10000 and it works but this is not equal to 1 month...

I also tried change int to double...long...etc but I still encounter the same Exception...how come when I tried changing 1000 to 10000 my program runs without that exception..any help with regards to this?

[1310 byte] By [ryshi1264a] at [2007-11-27 7:37:20]
# 1

The period is a long.

If you try to cram a number into an int that's larger than Integer.MAX_VALUE, it silently wraps around into the negative ints.

long period = 1000L * 3600 * 24 * 30

But why not just use your OS' scheduling service to kick off a Java process? Assuming the JVM will always be up for a once a month job is a dicey proposition.

Also note that this will run every 30 days, not once a month.

July 1

July 31

Aug 30

Sep 29

Oct 29

Nov 28

etc.

Next year it will run on different dates.

jverda at 2007-7-12 19:17:56 > top of Java-index,Java Essentials,Java Programming...
# 2
thank you so much,..i'll try to test my app with his..one question though..how will my OS scheduling service to kick off a Java process....i don't know this one..how do I use this one....
ryshi1264a at 2007-7-12 19:17:56 > top of Java-index,Java Essentials,Java Programming...
# 3
If it's unix/linux, it's cron. See the man pages or info pages for details.For Windows, it's the windows scheduler. You should be able to google or use windows help to find info.
jverda at 2007-7-12 19:17:56 > top of Java-index,Java Essentials,Java Programming...