TLE
Senior Newbie 
|
 |
«
Posted
2007-06-20 13:28:36 » |
|
Trying to set up some timer stuff, having trouble figuring out what to use. Was looking at using Calendar.get() with milli's and seconds, but looking at the way it's set up, it's not quite what I want. The problem is they wrap around too often, so i considered just writing an equation using the minutes and hour as well perhaps, which wouldn't wrap around very often, just twice a day. The problem here is that when it does wrap around, it could cause things to break for 12 hours, or possibly longer. Updating everything using the timers every time it wraps around is not an option -- at least I don't think I want to do that. How can I go about correcting these wrap arounds? Or if there's a better timer system I should use, what is it? For completeness, my timers are all consisting of a few seconds, around half a second to 10 seconds or so.
Just thinking about it a little more. Thinking maybe I could do an equation based on minutes/seconds/milli's, or maybe just seconds/milli's and instead of checking to see if the current time is greater than the end of the timer, I could check the absolute value of the difference. This will keep things from not working for a full wrap, but at the ends of the wraps it could cause timers to prematurely end, which, if happening only once an hour, that wouldn't be much of a problem. Still think there's a better way I'm overlooking. Ideas?
|