How to measure the running time of code in java

How to measure the running time of code in java
refe‮al:ot r‬utturi.com
import java.time.Duration;
import java.time.Instant;
public class RunningTime {
	public static void main(String[] args) {
		//start time
		Instant start = Instant.now();
		
		for(int idx = 1; idx <= 100000; idx++) {
			//System.out.println(idx);
		}			

		// end time
		Instant end = Instant.now();

		// running time of code
		System.out.println("Running time in ms: " + 
			Duration.between(start, end));
	}
}
Created Time:2017-09-12 10:17:49  Author:lautturi