public void test_ofDayOfMonth_31() { assertEquals(RollConvention.ofDayOfMonth(31), EOM); }
public void test_ofDayOfMonth_invalid() { assertThrowsIllegalArg(() -> RollConvention.ofDayOfMonth(0)); assertThrowsIllegalArg(() -> RollConvention.ofDayOfMonth(32)); }
public void test_ofDayOfMonth_matches_Day29() { assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, JANUARY, 30)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, JANUARY, 29)), true); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, JANUARY, 30)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, FEBRUARY, 28)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2016, FEBRUARY, 29)), true); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2015, FEBRUARY, 27)), false); assertEquals(RollConvention.ofDayOfMonth(29).matches(date(2015, FEBRUARY, 28)), true); }
public void test_ofDayOfMonth_matches_Day30() { assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, JANUARY, 29)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, JANUARY, 30)), true); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, JANUARY, 31)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, FEBRUARY, 28)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2016, FEBRUARY, 29)), true); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2015, FEBRUARY, 27)), false); assertEquals(RollConvention.ofDayOfMonth(30).matches(date(2015, FEBRUARY, 28)), true); }
public void test_ofDayOfMonth_next_oneMonth() { for (int start = 1; start <= 5; start++) { for (int i = 1; i <= 30; i++) { RollConvention test = RollConvention.ofDayOfMonth(i); LocalDate expected = date(2014, AUGUST, i); assertEquals(test.next(date(2014, JULY, start), P1M), expected); } } }
public void test_ofDayOfMonth_previous_oneMonth() { for (int start = 1; start <= 5; start++) { for (int i = 1; i <= 30; i++) { RollConvention test = RollConvention.ofDayOfMonth(i); LocalDate expected = date(2014, JUNE, i); assertEquals(test.previous(date(2014, JULY, start), P1M), expected); } } }
public void test_ofDayOfMonth_adjust_Day30() { assertEquals(RollConvention.ofDayOfMonth(30).adjust(date(2014, FEBRUARY, 2)), date(2014, FEBRUARY, 28)); assertEquals(RollConvention.ofDayOfMonth(30).adjust(date(2016, FEBRUARY, 2)), date(2016, FEBRUARY, 29)); }
public void test_ofDayOfMonth_adjust_Day29() { assertEquals(RollConvention.ofDayOfMonth(29).adjust(date(2014, FEBRUARY, 2)), date(2014, FEBRUARY, 28)); assertEquals(RollConvention.ofDayOfMonth(29).adjust(date(2016, FEBRUARY, 2)), date(2016, FEBRUARY, 29)); }
public void test_ofDayOfMonth_next_oneDay() { for (int start = 1; start <= 5; start++) { for (int i = 1; i <= 30; i++) { RollConvention test = RollConvention.ofDayOfMonth(i); LocalDate expected = date(2014, JULY, i); if (i <= start) { expected = expected.plusMonths(1); } assertEquals(test.next(date(2014, JULY, start), P1D), expected); } } }
public void test_ofDayOfMonth_previous_oneDay() { for (int start = 1; start <= 5; start++) { for (int i = 1; i <= 30; i++) { RollConvention test = RollConvention.ofDayOfMonth(i); LocalDate expected = date(2014, JULY, i); if (i >= start) { expected = expected.minusMonths(1); } assertEquals(test.previous(date(2014, JULY, start), P1D), expected); } } }
private static RollConvention impliedRollConvention( LocalDate date, LocalDate otherDate, Frequency frequency, boolean preferEndOfMonth) { if (frequency.isMonthBased()) { if (preferEndOfMonth && date.getDayOfMonth() == date.lengthOfMonth()) { return RollConventions.EOM; } return RollConvention.ofDayOfMonth(date.getDayOfMonth()); } else if (frequency.isWeekBased()) { return RollConvention.ofDayOfWeek(date.getDayOfWeek()); } else { // neither monthly nor weekly means no known roll convention return RollConventions.NONE; } }
public void test_ofDayOfMonth() { for (int i = 1; i < 30; i++) { RollConvention test = RollConvention.ofDayOfMonth(i); assertEquals(test.adjust(date(2014, JULY, 1)), date(2014, JULY, i)); assertEquals(test.getName(), "Day" + i); assertEquals(test.toString(), "Day" + i); assertSame(RollConvention.of(test.getName()), test); assertSame(RollConvention.of("DAY" + i), test); } }
RollConvention.ofDayOfMonth(Math.max(start.getDayOfMonth(), end.getDayOfMonth()));
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, AUSY)) .frequency(Frequency.P3M) .rollConvention(RollConvention.ofDayOfMonth(29)) .build()) .paymentSchedule(PaymentSchedule.builder()
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, FRPA)) .frequency(Frequency.P6M) .rollConvention(RollConvention.ofDayOfMonth(14)) .build()) .paymentSchedule(PaymentSchedule.builder() .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, FRPA)) .frequency(Frequency.P12M) .rollConvention(RollConvention.ofDayOfMonth(14)) .build()) .paymentSchedule(PaymentSchedule.builder()
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, USNY)) .frequency(Frequency.P3M) .rollConvention(RollConvention.ofDayOfMonth(30)) .build()) .paymentSchedule(PaymentSchedule.builder() .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, USNY)) .frequency(Frequency.P6M) .rollConvention(RollConvention.ofDayOfMonth(30)) .build()) .paymentSchedule(PaymentSchedule.builder()
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY)) .frequency(Frequency.P3M) .rollConvention(RollConvention.ofDayOfMonth(27)) .build()) .paymentSchedule(PaymentSchedule.builder() .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY)) .frequency(Frequency.P6M) .rollConvention(RollConvention.ofDayOfMonth(27)) .build()) .paymentSchedule(PaymentSchedule.builder()
.endDateBusinessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)) .frequency(Frequency.P3M) .rollConvention(RollConvention.ofDayOfMonth(22)) .build()) .paymentSchedule(PaymentSchedule.builder()
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)) .frequency(Frequency.P6M) .rollConvention(RollConvention.ofDayOfMonth(14)) .build()) .paymentSchedule(PaymentSchedule.builder() .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)) .frequency(Frequency.P12M) .rollConvention(RollConvention.ofDayOfMonth(14)) .build()) .paymentSchedule(PaymentSchedule.builder()
.businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN)) .frequency(Frequency.P3M) .rollConvention(RollConvention.ofDayOfMonth(27)) .build()) .paymentSchedule(PaymentSchedule.builder() .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN)) .frequency(Frequency.P6M) .rollConvention(RollConvention.ofDayOfMonth(27)) .build()) .paymentSchedule(PaymentSchedule.builder()