public static int toMonths(int year, int months)
    {
        try {
            return addExact(multiplyExact(year, 12), months);
        }
        catch (ArithmeticException e) {
            throw new IllegalArgumentException(e);
        }
    }
@Test
    public void testMaxYears()
    {
        int years = Integer.MAX_VALUE / 12;
        assertEquals(toMonths(years, 0), years * 12);
    }