public static Timer deadlineTimer(final Time time, final long deadlineMs) {
        long diff = Math.max(0, deadlineMs - time.milliseconds());
        return time.timer(diff);
    }
@Test
    public void testDeadlineTimer() {
        long deadlineMs = time.milliseconds() + DEFAULT_TIMEOUT_MS;
        Timer timer = TimedRequestState.deadlineTimer(time, deadlineMs);
        assertEquals(DEFAULT_TIMEOUT_MS, timer.remainingMs());
        timer.sleep(DEFAULT_TIMEOUT_MS);
        assertEquals(0, timer.remainingMs());
    }