### Question:
SummarizerUtils { public static String datePeriod(LocalDate start, LocalDate end) { int months = Math.toIntExact(MONTHS.between(start, end.plusDays(3))); if (months > 0) { return Tenor.of(Period.ofMonths((int) months)).normalized().toString(); } else { return Tenor.of(Period.ofDays((int) start.until(end, ChronoUnit.DAYS))).toString(); } } private  SummarizerUtils(); static String date(LocalDate date); static String dateRange(LocalDate start, LocalDate end); static String datePeriod(LocalDate start, LocalDate end); static String amount(CurrencyAmount currencyAmount); static String amount(Currency currency, double value); static String value(double value); static String percent(double value); static String payReceive(PayReceive payReceive); static String fx(CurrencyAmount base, CurrencyAmount counter); static PortfolioItemSummary summary(Position position, ProductType type, String description, Currency... currencies); static PortfolioItemSummary summary(Trade trade, ProductType type, String description, Currency... currencies);  }### Answer:
@Test public void test_datePeriod() { assertThat(SummarizerUtils.datePeriod(LocalDate.of(2017, 10, 12), LocalDate.of(2019, 10, 12))).isEqualTo("2Y"); assertThat(SummarizerUtils.datePeriod(LocalDate.of(2017, 10, 12), LocalDate.of(2019, 12, 12))).isEqualTo("2Y2M"); }
@Test public void test_under1MonthPeriod() { assertThat(SummarizerUtils.datePeriod(LocalDate.of(2014, 8, 6), LocalDate.of(2014, 8, 24))).isEqualTo("18D"); }