Problem calling method rec
folks here's a look at my code
public Date getBusinessDate(Date start , Date end )
{
int days = 0;
Calendar startcal = Calendar.getInstance();
startcal.setTime(start);
while(startcal.getTime().getTime() < end.getTime())
{
startcal.add(Calendar.DATE,1);
int day = startcal.get(Calendar.DAY_OF_WEEK);
if( day == Calendar.MONDAY || day == Calendar.TUESDAY || day == Calendar.WEDNESDAY ||
day == Calendar.THURSDAY || day == Calendar.FRIDAY)
{
continue;
}
days++;
}
startcal.add(Calendar.DATE , (days));
Date recursiveEnd = startcal.getTime();
if(days > 0)
{
getBusinessDate(end , recursiveEnd);
}
System.out.println("The date is"+recursiveEnd);
return (recursiveEnd);
}
what I am trying to do here is trying to pass on 2 dates to this method which in turn will return me result date which takes into account the weekends and does not count the weekends (it just counts the business days).
I am calling the function again at the end to make sure that the days added to startcal object does not have a weekend again.
my output with the final println is
The date isMon Jan 01 09:44:43 GMT-05:00 2007
The date isMon Jan 01 09:44:43 GMT-05:00 2007
The date isSun Dec 31 09:44:43 GMT-05:00 2006
The date isSat Dec 30 09:44:43 GMT-05:00 2006
i do not have the println in a loop and it still prints 4 times why?
jan 01 is the date it shld be returnin then why is it returnin dec 30?
thanks a lot for your patience

