[JAVA] more precise timestamp (nanometer timestamp) than millisecond system.currenttimemillis ()

Source: Internet
Author: User

?? nanosecond NS (nanosecond): nanoseconds,Time Unit。 One of the 1 billion points in a second, which equals 10 minus 9 seconds.

A unit that is often used as a memory read/write speed, the lower the number, the faster.

1 nanoseconds =1000Leather seconds1 nanoseconds =0.001microseconds1 nanoseconds =0.000001milliseconds

1 nanoseconds =0.00000 0001 sec

What is the difference between Java's System.currenttimemillis () and System.nanotime ()

In Java, System.nanotime () returns nanoseconds. Nanotime and return may be random time, even may be negative ... Follow the API's instructions. The basic use of nanotime is to measure a period of time, such as the time it takes to run a code, the time it takes to get a database connection, the time it takes to access the network, and so on. Other than that. Nanotime provides the nanosecond level of precision, but the actual value obtained may not be accurate to nanoseconds.

but in general, the purpose of these two functions is completely different! .

The milliseconds that System.currenttimemillis () returns in Java, which in fact is the number of milliseconds since 0 o'clock January 1, 1970. Date () is actually equivalent to date (System.currenttimemillis ()), because the date class has a constructed date (long date). Used to calculate the millisecond difference between long seconds and January 1, 1970.

[JAVA] more precise timestamp (nanometer timestamp) than millisecond system.currenttimemillis ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.