sean
----- Original Message ----- From: "Stephen Colebourne" <[EMAIL PROTECTED]>
To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
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" <[EMAIL PROTECTED]>
What does JODA time do, if anything about this?
Gary
the-----Original Message----- From: Sean Schofield [mailto:[EMAIL PROTECTED] 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 includeddayOfWeek,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, intdaysOfWeek,int increment) { int[] dateArray = {dayOfWeek}; return adjustUntilNot(originalDate, dateArray, increment); }
public static Date adjustUntilNot(Date originalDate, int[]weekendsint 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" <[EMAIL PROTECTED]> To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]> 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 SatSunofas > a > default, but an API should probably be framed to allow the avoidancedefine.> any > day of week combination. And that can get to be a tricky API to> > Stephen >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
