Usage and meaning of Currenttimemillis in Java.

Source: Internet
Author: User


Usage:
Can be used to get the current time of the number of milliseconds, the number of milliseconds can be compared by time, time conversion and time formatting and so on.
public class SystemTime {
public static void Main (string[] args) {
Defining the time variables that were running
Long time = System.currenttimemillis ();
The number of milliseconds to print the start time
System.out.println (time);
for (int i =0;i<10000;i++) {
You don't have to do anything.
}
System.out.println (the time required for the For Loop to run (in milliseconds) + (System.currenttimemillis ()-time));
System.out.println ("For Loop run time required (seconds)" + (System.currenttimemillis ()-time)/1000);
System.out.println ("Show Current Time:" +new simpledateformat ("Yyyy-mm-dd HH:mm:ss"). Format (System.currenttimemillis ()));
}
}
Meaning:
The primary is to return the current time in milliseconds, and the granularity of the value depends on the different operating systems:

Usage and meaning of Currenttimemillis in Java.

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.