- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to get the current value of the system timer in nanoseconds
Use System.nanoTime() method in Java to get the current value of the system timer in nanoseconds. It d returns the current value of the most precise available system timer, in nanoseconds.
We are getting the system timer value in a long type −
long res = System.nanoTime();
The following is an example −
Example
public class Demo { public static void main(String[] args) { long res = System.nanoTime(); System.out.println("Current Value: " + res + " nanoseconds"); } }
Output
Current Value: 49908709882168 nanoseconds
Advertisements