commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Schofield" <sean_schofi...@schof.com>
Subject Re: [lang] Enhancement proposal for DateUtils
Date Wed, 22 Sep 2004 22:27:27 GMT
In the interest of full disclosure I also wanted to point out that code 
still assumes a Gregorian calendar.  It does not assume that a weekend is 
Saturday or Sunday which I think was the key concern earlier.

sean

----- Original Message ----- 
From: "Stephen Colebourne" <scolebourne@btopenworld.com>
To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
Sent: Wednesday, September 22, 2004 6:11 PM
Subject: Re: [lang] Enhancement proposal for DateUtils


> Joda-time has no handling for weekend style concepts at present.
>
> Stephen
>
> ----- Original Message ----- 
> From: "Gary Gregory" <ggregory@seagullsoftware.com>
> What does JODA time do, if anything about this?
>
> Gary
>
>> -----Original Message-----
>> From: Sean Schofield [mailto:sean_schofield@schof.com]
>> Sent: Wednesday, September 22, 2004 14:31
>> To: Jakarta Commons Developers List
>> Subject: Re: [lang] Enhancement proposal for DateUtils
>>
>> OK,
>>
>> I gave the weekend adjustment thing some thought.  What if we included
> the
>> following methods?  (NOTE: javadoc, patches, and unit tests will be
>> provided
>> later if we go with this idea.)
>>
>> Thoughts?
>> sean
>>
>>
>>     public static int[] SATURDAY_SUNDAY = {Calendar.SATURDAY,
>> Calendar.SUNDAY};
>>
>>     public static Date adjustUntilNot(Date originalDate, int
> dayOfWeek,
>> int
>> increment) {
>>         int[] dateArray = {dayOfWeek};
>>         return adjustUntilNot(originalDate, dateArray, increment);
>>     }
>>
>>     public static Date adjustUntilNot(Date originalDate, int[]
> daysOfWeek,
>> int increment) {
>>         Date adjustedDate = originalDate;
>>         Calendar calendar = new GregorianCalendar();
>>
>>         while (fallsOn(adjustedDate, daysOfWeek)) {
>>             calendar.add(Calendar.DATE, increment);
>>             adjustedDate = calendar.getTime();
>>         }
>>
>>         return adjustedDate;
>>     }
>>
>>     public static boolean fallsOn(Date date, int dayToCheck) {
>>         int[] daysToCheck = {dayToCheck};
>>         return fallsOn(date, daysToCheck);
>>     }
>>
>>     public static boolean fallsOn(Date date, int[] daysToCheck) {
>>         Calendar calendar = new GregorianCalendar();
>>         calendar.setTime(date);
>>         int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
>>
>>         for (int i=0; i < daysToCheck.length; i++) {
>>             if (dayOfWeek == daysToCheck[i]) {
>>                 return true;
>>             }
>>         }
>>
>>         return false;
>>     }
>>
>> ----- Original Message -----
>> From: "Stephen Colebourne" <scolebourne@btopenworld.com>
>> To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
>> Sent: Sunday, September 12, 2004 10:06 AM
>> Subject: Re: [lang] Enhancement proposal for DateUtils
>>
>>
>> > Its a point for debate really. It might be OK to define SatSun
> weekends
>> as
>> > a
>> > default, but an API should probably be framed to allow the avoidance
> of
>> > any
>> > day of week combination. And that can get to be a tricky API to
> define.
>> >
>> > Stephen
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
> 



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