You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue during a refactor in our code base. I assumed the JavaDoc to be true, however the statement about zero business days is false.
/**
* Find a new date by adding the given number of business days to a given base date.
*
* If baseDate is not a business date and businessDays is zero, the method returns the next business day.
*
* @param baseDate The starting date.
* @param businessDays The number of business days from the starting date (negative values are allowed).
* @return A date of a business day such that the number of business days between this one (including) and the start date (excluding) is businessDays.
*/
LocalDate getRolledDate(LocalDate baseDate, int businessDays);
The javadoc indicates that getRolledDate always returns a bussiness day, even if 0 business days are given.
Meanwhile in AbstractBusinessdayCalendar:
@Override
public LocalDate getRolledDate(final LocalDate baseDate, int businessDays) {
LocalDate rolledDate = baseDate;
final int direction = businessDays >= 0 ? 1: -1;
final DateRollConvention dateRollConvention = direction > 0 ? DateRollConvention.FOLLOWING : DateRollConvention.PRECEDING;
while(businessDays != 0) { // business day == 0 so while loop does not get executed
rolledDate = rolledDate.plusDays(direction);
rolledDate = getAdjustedDate(rolledDate, dateRollConvention);
businessDays -= direction;
}
return rolledDate; // is still equal to the basedate.
}
The implementation just returns the given date when there are 0 business days given.
I think by this point the JavaDoc should be fixed as changing the implementation will probably cause breakage.
The text was updated successfully, but these errors were encountered:
Snijder
changed the title
BussinessDatCalendar JavaDoc does not match implementation
BussinessDateCalendar getRolledDate JavaDoc does not match implementation
Sep 11, 2024
I ran into an issue during a refactor in our code base. I assumed the JavaDoc to be true, however the statement about zero business days is false.
The javadoc indicates that getRolledDate always returns a bussiness day, even if 0 business days are given.
Meanwhile in AbstractBusinessdayCalendar:
The implementation just returns the given date when there are 0 business days given.
I think by this point the JavaDoc should be fixed as changing the implementation will probably cause breakage.
The text was updated successfully, but these errors were encountered: