Java gets current system time System.currenttimemillis ()

Source: Internet
Author: User

System.currenttimemillis () produces a current millisecond, which is actually the number of milliseconds since 0 o'clock January 1, 1970, and date () is actually the equivalent of date (System.currenttimemillis ()); Because the date class has a constructed date (long date), it is used to calculate the millisecond difference between long and January 1, 1970.
Given this millisecond, we can count the current day and the week, but this is not what we calculate, because there is a calendar. The final result of the calendar is the day of the month and the week zone.
System.currenttimemillis () Gets the time distance from 1970-1-01 00:00:00.000 to the current moment, type long
String.valueof (System.currenttimemillis ()) This statement can be converted to the following pattern:
Long ct = System.currenttimemillis ();
String t = string.valueof (CT);
In fact, the above string T is equivalent to ct+ "";
Just convert to string format

Public String refformatnowdate () {
Date Nowtime = new Date (System.currenttimemillis ());
SimpleDateFormat sdformatter = new SimpleDateFormat ("Yyyy-mm-dd");
String retstrformatnowdate = Sdformatter.format (nowtime);

return retstrformatnowdate;
}

Java gets current system time System.currenttimemillis ()

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.