devxlogo

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

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:

[root@mypc]# java NanoTimeInJava
Time in nano seconds : 698344477290095

*/

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist