commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject [lang] Addition for DataUtils
Date Tue, 01 Mar 2005 19:43:29 GMT
Hello... I just had to whip up a function that might be useful...

The situation was that I needed to determine if the current time fell 
within a given range.  The complication is that the range could span a 
day, i.e., the range might be 2000-0800 (24 hr. times).

So I threw together

static boolean isTimeInRange(int rangeStart, int rangeEnd, int timeToCheck);

...the idea being that someone would do something like:

int now = 100 * new GregorianCalendar().get(Calendar.HOUR_OF_DAY);
if (isTimeInRange(800, 2000, now)) {
   // in range
}

I'm wondering if that sounds like a good edition to DateUtils?

If so, I'll create some overloaded versions (to accept actual Calendars 
and probably Strings in addition to ints, and mixtures of all three, 
perhaps 12-hour times too), solidify and clean up the code, throw 
together a unit test and post it to Bugzilla.

Any thoughts?  Part of me expects to hear this already exists somewhere, 
but I didn't find it in DateUtils, which strikes me as the logical 
place.  Thanks all!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message