JAVA : System.currentTimeMillis()

JAVA : System.currentTimeMillis()

System.currentTimeMillis()

  • returns current value of running java virtual machine high resolution time source in nanoseconds.
  • The value returned represents nanoseconds since some fixed but arbitrary origin time,
  • other jvm instance will use different origin. Origin is nothing but used to keep track of the time from the start of the jvm
  • long startTime=System.currentTimeMillis();
    //output : 1663132233612
    
How to use this
 long startTime = System.nanoTime(); 
   // ... the code being measured ...   
 long estimatedTime = System.nanoTime() - startTime;