Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BussinessDateCalendar getRolledDate JavaDoc does not match implementation #94

Open
Snijder opened this issue Sep 11, 2024 · 0 comments
Open

Comments

@Snijder
Copy link

Snijder commented 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.

	/**
	 * 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.

@Snijder Snijder changed the title BussinessDatCalendar JavaDoc does not match implementation BussinessDateCalendar getRolledDate JavaDoc does not match implementation Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant