Results 1 to 6 of 6
Thread: DATE in JAVA
- 10-05-2009, 10:47 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 15
- Rep Power
- 0
DATE in JAVA
hi,
my program needs to run a particular process only between say, 9 am to 5 pm every day. and if the system time is not between this, the if shud not be executed.
how to obtain such a functioanality. I would prefer the start time and end time to be configurable , to be picked up from a properties file.
any clues..??
- 10-05-2009, 11:08 PM #2
Java Code:Calendar calendar = GregorianCalendar.getInstance(); System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
Also: Properties in javaMy Hobby Project: LegacyClone
-
Unix or Windows (or other)? I believe that unix OS has this timer functionality built in to it, and it could possibly even start up your app each day at a certain time.
Also, does your program need to use a java.util.Timer?
- 10-06-2009, 03:50 AM #4
Member
- Join Date
- Oct 2009
- Posts
- 15
- Rep Power
- 0
there are 3 threads running at the moment.. all kicked off from the same java class..
with sleep times configured.. so once the thread.sleep() is invoked, it sleeps for the specified time..
all three threads function the same way..
but i need one of these threads to run between a particular duration of the day.. and rest of the time.. run/sleep.. but shud not perform the functionality that is expected out of it..
- 10-06-2009, 03:52 AM #5
Member
- Join Date
- Oct 2009
- Posts
- 15
- Rep Power
- 0
using windows OS.. the entire program is goin to be deployed on unix but.. is it possible to control jus one thread in UNIX..??
the whole program as such will be running based on a particular time line..
- 10-06-2009, 07:10 AM #6
Java Code:public void run() { while(running) { ... Calendar calendar = GregorianCalendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); while( hour <9 || hour >= 17 ) { if(!running) return; try { sleep(1000); //or some other time amount }catch(Exception e) {} } ... } }Last edited by mrmatt1111; 10-06-2009 at 07:17 AM.
My Hobby Project: LegacyClone
Similar Threads
-
java.util.Date vs java.sql.Date
By Jack in forum New To JavaReplies: 5Last Post: 10-28-2010, 02:59 PM -
Compare date input to database with current date
By hungleon88 in forum Advanced JavaReplies: 2Last Post: 11-25-2008, 08:10 AM -
Creating a Gregorian Calendar using a Date object gives date - 1
By prachi_goliwadekar in forum New To JavaReplies: 1Last Post: 05-08-2008, 08:32 PM -
Difference between current date and anothe date
By vijay balusamy in forum New To JavaReplies: 1Last Post: 04-16-2008, 04:15 PM -
Using java.sql.Date
By Java Tip in forum Java TipReplies: 0Last Post: 02-10-2008, 11:32 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks