import java.time.Duration;
import java.time.Instant;
public class RunningTime {
public static void main(String[] args) {
// Create a first time stamp
Instant start = Instant.now();
// Time-consuming code
for(int idx = 1; idx <= 1000_000_000; idx++) {
System.out.println(idx);
}
// Create a second time stamp
Instant end = Instant.now();
// Measure time elapsing between 2 time stamps
System.out.println("Running time in ms: " +
Duration.between(start, end));
}
}