package testexample; public class Testexample { public static void main(String[] args) { long start = System.currentTimeMillis(); // 1s = 1000ms for (int i=1; i<1000000; i++); long end = System.currentTimeMillis(); long time = end - start; System.out.println("Miliseconds: " + time); // 1 milisecond System.out.println("Seconds: " + microtime(time)); // 0.0010 seconds } public static double microtime(long time) { long seconds = time / 1000; double decimal = (time - (seconds*1000))/1000d; // 1000d = 1000.0 equivalent with (double)1000 return decimal + seconds; } }