public static int toMonths(int year, int months)
    {
        try {
            return addExact(multiplyExact(year, 12), months);
        }
        catch (ArithmeticException e) {
            throw new IllegalArgumentException(e);
        }
    }
@Test(expectedExceptions = IllegalArgumentException.class)
    public void testOverflow()
    {
        int days = (Integer.MAX_VALUE / 12) + 1;
        toMonths(days, 0);
    }