//------------------------------------------------------------------------- /// <summary> /// Adjusts the date, adding the tenor and then applying the business day adjustment. /// <para> /// The calculation is performed in two steps. /// </para> /// <para> /// Step one, use <seealso cref="PeriodAdditionConvention#adjust(LocalDate, Period, HolidayCalendar)"/> to add the period. /// </para> /// <para> /// Step two, use <seealso cref="BusinessDayAdjustment#adjust(LocalDate, ReferenceData)"/> to adjust the result of step one. /// /// </para> /// </summary> /// <param name="date"> the date to adjust </param> /// <param name="refData"> the reference data, used to find the holiday calendar </param> /// <returns> the adjusted date </returns> public LocalDate adjust(LocalDate date, ReferenceData refData) { HolidayCalendar holCal = adjustment.Calendar.resolve(refData); BusinessDayConvention bda = adjustment.Convention; return(bda.adjust(additionConvention.adjust(date, tenor.Period, holCal), holCal)); }
/// <summary> /// Resolves this adjustment using the specified reference data, returning an adjuster. /// <para> /// This returns a <seealso cref="DateAdjuster"/> that performs the same calculation as this adjustment. /// It binds the holiday calendar, looked up from the reference data, into the result. /// As such, there is no need to pass the reference data in again. /// /// </para> /// </summary> /// <param name="refData"> the reference data, used to find the holiday calendar </param> /// <returns> the adjuster, bound to a specific holiday calendar </returns> public DateAdjuster resolve(ReferenceData refData) { HolidayCalendar holCal = adjustment.Calendar.resolve(refData); BusinessDayConvention bda = adjustment.Convention; return(date => bda.adjust(additionConvention.adjust(date, period, holCal), holCal)); }
/// <summary> /// Resolves this adjustment using the specified reference data, returning an adjuster. /// <para> /// This returns a <seealso cref="DateAdjuster"/> that performs the same calculation as this adjustment. /// It binds the holiday calendar, looked up from the reference data, into the result. /// As such, there is no need to pass the reference data in again. /// </para> /// <para> /// The resulting adjuster will be <seealso cref="#normalized() normalized"/>. /// /// </para> /// </summary> /// <param name="refData"> the reference data, used to find the holiday calendar </param> /// <returns> the adjuster, bound to a specific holiday calendar </returns> public DateAdjuster resolve(ReferenceData refData) { HolidayCalendar holCalAdj = adjustment.Calendar.resolve(refData); if (calendar == HolidayCalendarIds.NO_HOLIDAYS) { BusinessDayConvention adjustmentConvention = adjustment.Convention; return(date => adjustmentConvention.adjust(LocalDateUtils.plusDays(date, days), holCalAdj)); } HolidayCalendar holCalAdd = calendar.resolve(refData); BusinessDayConvention adjustmentConvention = adjustment.Convention; return(date => adjustmentConvention.adjust(holCalAdd.shift(date, days), holCalAdj)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "convention") public void test_convention(BusinessDayConvention convention, java.time.LocalDate input, java.time.LocalDate expected) public virtual void test_convention(BusinessDayConvention convention, LocalDate input, LocalDate expected) { assertEquals(convention.adjust(input, HolidayCalendars.SAT_SUN), expected); }