More precise details of time can be obtained in Java using nanoTime()

Code snippet:

public class NanoTimeInJava
{
public static void main(String args[])
{
NanoTimeInJava nanoTimeInJava = new NanoTimeInJava();
nanoTimeInJava.proceed();
}

private void proceed()
{
//The following nanoTime() method in System class provides the time in nano seconds
System.out.println(“Time in nano seconds : “+System.nanoTime());
}
}

/*

Expected output:

[[email protected]]# java NanoTimeInJava
Time in nano seconds : 698344477290095

*/

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: