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 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");
    }