fork download
  1. import java.time.Instant;
  2. import java.time.temporal.ChronoUnit;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. // This is a sample Instant. In your case, it will be returned by
  7. // timeService.getDate().toInstant()
  8. Instant today = Instant.now();
  9.  
  10. // This is a sample Instant after one day. In your case, it will be returned by
  11. // timeService.getDateAfter(1).toInstant()
  12. Instant tomorrow = today.plus(1, ChronoUnit.DAYS);
  13.  
  14. long seconds = today.until(tomorrow, ChronoUnit.SECONDS);
  15.  
  16. // In your case, you will use Assertions.assertEquals(86400, seconds);
  17. System.out.println(seconds);
  18. }
  19. }
Success #stdin #stdout 0.06s 47800KB
stdin
Standard input is empty
stdout
86400