Timing Arrays Method sort with Date/Time API Classes Instant and Duration
Lines 22 and 24 each call class Instant
’s static
method now to get the current time before and after the call to sort
. To determine the difference between two Instant
s, line 27 uses class Duration
’s static
method between, which returns a Duration
object containing the time difference. Next, we call Duration
method toMillis to get the difference in milliseconds.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.