Forums Register Login

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

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1266 times.
Similar Threads
XSLT vs. JSP
Better way to determine current directory...
Best Technology/Practice for Java to XML transformation for XSD
Need help on DOM Syllabus
Properties File?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:38:23.