> Hi there,
>
[quoted text clipped - 4 lines]
>
> private Date m_endDate;
First of all, get rid of that annoying "m_" prefix. No one will steal
your variables while you look away, so no need to to mark them as "my
variables".
For the rest, here is a rough cut (untested). If I would have to code it
in real life I would first introduce a class like DateRange and provide
it with some intersection() method and a range Interator or similar.
GregorianCalendar start = new GregorianCalender();
start.setTime(m_startDate);
// probably reset time fields to zero
GregorianCalendar end = new GregorianCalendar();
end.setTime(m_endDate);
// probably reset time fields to zero
GregorianCalendar targetStart =
new GregorianCalendar(targetYear, targetMonth, 1);
GregorianCalendar targetEnd = (GregorianCalendar) targetStart.clone();
targetEnd.set(Calendar.DAY_OF_MONTH,
targetEnd.getActualMaximum(Calendar.DAY_OF_MONTH));
GregorianCalendar resultStart = start;
GregorianCalendar resultEnd = end;
if(targetStart.after(start) {
resultStart = targetStart;
}
if(targetEnd.before(end)) {
resultEnd = targetEnd;
}
while(resultEnd.after(resultStart)) {
System.out.println(resultStart);
resultStart.add(Calendar.DAY_OF_MONTH, 1);
}
> This has fried my head and I am at a loss to think of a nice solution.
First it has to work. Then you can make it nice. E.g. by introducing the
above mentioned DateRange (or a CalendarRange) class.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/