Deadline { public TimeValue remainingTimeValue() { return TimeValue.of(remaining(), TimeUnit.MILLISECONDS); } private  Deadline(final long deadlineMillis); static Deadline calculate(final long timeMillis, final TimeValue timeValue); static Deadline calculate(final TimeValue timeValue); static Deadline fromUnixMilliseconds(final long value); static Deadline parse(final String source); @Override boolean equals(final Object obj); String format(final TimeUnit overdueTimeUnit); String formatTarget(); Deadline freeze(); long getValue(); @Override int hashCode(); boolean isBefore(final long millis); boolean isExpired(); boolean isMax(); boolean isMin(); boolean isNotExpired(); Deadline min(final Deadline other); long remaining(); TimeValue remainingTimeValue(); @Override String toString(); static final String DATE_FORMAT; static Deadline MAX_VALUE; static Deadline MIN_VALUE; }
@Test public void testRemainingTimeValue() { final int oneHourInMillis = 60_000 * 60; final long nowPlusOneHour = System.currentTimeMillis() + oneHourInMillis; final Deadline deadline = Deadline.fromUnixMilliseconds(nowPlusOneHour); Assert.assertEquals(nowPlusOneHour, deadline.getValue()); Assert.assertTrue(deadline.remainingTimeValue().toNanoseconds() > 0); Assert.assertTrue(deadline.remainingTimeValue().toMicroseconds() > 0); Assert.assertTrue(deadline.remainingTimeValue().toMilliseconds() > 0); }