### Question:
IntervalYearMonth { public static int toMonths(int year, int months) { try { return addExact(multiplyExact(year, 12), months); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } private  IntervalYearMonth(); static int toMonths(int year, int months); static String formatMonths(int months); static int parseMonths(String value);  }### Answer:
@Test public void testFormat() { assertMonths(0, "0-0"); assertMonths(toMonths(0, 0), "0-0"); assertMonths(3, "0-3"); assertMonths(-3, "-0-3"); assertMonths(toMonths(0, 3), "0-3"); assertMonths(toMonths(0, -3), "-0-3"); assertMonths(28, "2-4"); assertMonths(-28, "-2-4"); assertMonths(toMonths(2, 4), "2-4"); assertMonths(toMonths(-2, -4), "-2-4"); assertMonths(Integer.MAX_VALUE, "178956970-7"); assertMonths(Integer.MIN_VALUE + 1, "-178956970-7"); assertMonths(Integer.MIN_VALUE, "-178956970-8"); }
@Test public void testMaxYears() { int years = Integer.MAX_VALUE / 12; assertEquals(toMonths(years, 0), years * 12); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testOverflow() { int days = (Integer.MAX_VALUE / 12) + 1; toMonths(days, 0); }