commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Pugh" <>
Subject RE: [lang] Addition for DataUtils
Date Wed, 02 Mar 2005 17:28:33 GMT
I need the same logic..  Is it something you can share/ post to the


-----Original Message-----
From: Frank W. Zammetti [] 
Sent: Tuesday, March 01, 2005 11:43 AM
To: Commons Developer
Subject: [lang] Addition for DataUtils

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

...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

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message