List of usage examples for java.time Duration toString
@Override
public String toString()
From source file:Main.java
public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON); System.out.println(duration.getSeconds()); System.out.println(duration.toString()); }
From source file:com.drunkendev.io.recurse.tests.RecursionTest.java
/** * Times a {@link Runnable} instance.//from ww w. ja va2 s. c om * * @param r * {@link Runnable} object to time. * @return {@link Duration} object containing run-time length. */ public Duration time(Runnable r) { Instant start = Instant.now(); r.run(); Duration dur = Duration.between(start, Instant.now()); System.out.format("Completed in: %s%n", dur.toString()); return dur; }