public static long toMillis(long day, long hour, long minute, long second, long millis)
    {
        try {
            long value = millis;
            value = addExact(value, multiplyExact(day, MILLIS_IN_DAY));
            value = addExact(value, multiplyExact(hour, MILLIS_IN_HOUR));
            value = addExact(value, multiplyExact(minute, MILLIS_IN_MINUTE));
            value = addExact(value, multiplyExact(second, MILLIS_IN_SECOND));
            return value;
        }
        catch (ArithmeticException e) {
            throw new IllegalArgumentException(e);
        }
    }
@Test
    public void testFormat()
    {
        assertMillis(0, "0 00:00:00.000");
        assertMillis(1, "0 00:00:00.001");
        assertMillis(-1, "-0 00:00:00.001");

        assertMillis(toMillis(12, 13, 45, 56, 789), "12 13:45:56.789");
        assertMillis(toMillis(-12, -13, -45, -56, -789), "-12 13:45:56.789");

        assertMillis(Long.MAX_VALUE, "106751991167 07:12:55.807");
        assertMillis(Long.MIN_VALUE + 1, "-106751991167 07:12:55.807");
        assertMillis(Long.MIN_VALUE, "-106751991167 07:12:55.808");
    }