Java execution time

long startTime = System.nanoTime();
someProcessing();
long endTime = System.nanoTime();
//timeDuration will be in milliseconds, Divide by 1000000 to get milliseconds.
long timeDuration = (endTime - startTime);