Easy learning with example program codes

Java calculate elapsed time

Java calculate elapsed time example

package com.codesjava;
import java.util.concurrent.TimeUnit;
public class ElapsedTimeTest {
  public static void main(String args[]) throws InterruptedException{
	  long lStartTime = System.nanoTime();
	  long lEndTime = System.nanoTime();
	  //time elapsed
	  long output = lEndTime - lStartTime;
	  System.out.println("Elapsed time in milliseconds: " + output / 1000000);
  private static void calculation() throws InterruptedException {
      //Sleep 3 seconds


Elapsed time in milliseconds: 3002
Posted in Date   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki