For any specific recurrence, you may well be able to code a solution,
but you're going to run in to trouble at some point.

For recurrences you're probably best off using a recurrence library like
http://code.google.com/p/google-rfc-2445/

Something like this should work:

final RRule rRule = new RRule();
rRule.setFreq(Frequency.MONTHLY);
rRule.setByDay(Collections.singletonList(new WeekdayNum(3, Weekday.FR)));
RecurrenceIterator it =
RecurrenceIteratorFactory.createRecurrenceIterator(rRule, startDate,
timeZone);


Johan Van den Neste



On Tue, Feb 23, 2010 at 6:34 PM, Roque Martinez <[email protected]> wrote:
> Adam;
> Thanks, I have used your code instead.
>
> Rocky
>
> On Tue, Feb 23, 2010 at 12:03 PM, Adam Vartanian <[email protected]> wrote:
>>
>> > I have used joda for some projects. I have a requierment to calculate
>> > the
>> > third Friday of any month. Is below the most effecient
>>
>> Probably easier to see what you're doing if you do something like this:
>>
>> DateTime getThirdFridayOfMonth(DateTime date) {
>>  DateTime first = date.withDayOfMonth(1);
>>  if (first.getDayOfWeek() > DateTimeConstants.FRIDAY) {
>>    return first.plusWeeks(3).withDayOfWeek(DateTimeConstants.FRIDAY);
>>  } else {
>>    return first.plusWeeks(2).withDayOfWeek(DateTimeConstants.FRIDAY);
>>  }
>> }
>>
>> = Adam
>
>
>
> --
> http://rmtechsys.blogspot.com/
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to