Use System.nanoTime to get the current time.
long startTime = System.nanoTime();
.....your program....
long endTime = System.nanoTime();
long totalTime = endTime - startTime;
System.out.println(totalTime);
The above code prints the running time of the program in nanoseconds.