aspose file tools*
The moose likes Java in General and the fly likes Best practice to use timers to check current time and xml file records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Best practice to use timers to check current time and xml file records " Watch "Best practice to use timers to check current time and xml file records " New topic
Author

Best practice to use timers to check current time and xml file records

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
Hi
Thank you for reading my post
I have an xml file which has some node showing time ranges.
I should check this time ranges and compare the current time with stored time ranges, if current time is within those time range, I need to perform some actions.

Are there any pattern or best practice for it?

Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19542
    
  16

How are the time ranges stored? As a begin date/time and end/date time?

If so, convert them to a Date object using java.text.DateFormat and/or java.textSimpleDateFormat, create a new Date object without parameters (new Date() will give a Date object for the current moment) and use their compareTo methods.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
Thank you for the reply.
Problem that I can not resolve is, should I use a Timer to read the file in intevral and check the time range or there are other low overhead method for performing this?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Timer should be fine. Set one to repeat every hour or minutes or whatever you need.

Does the file change? If not, it should be easy to read it once and schedule Timer events for time ranges that are in the future. Tools like Quartz and Cron handle complex schedules.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best practice to use timers to check current time and xml file records
 
Similar Threads
XSLT vs. JSP
Better way to determine current directory...
Need help on DOM Syllabus
Properties File?
Best Technology/Practice for Java to XML transformation for XSD