Java get current system event System.currenttimemillis ()

Source: Internet
Author: User
Tags string format

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 also has a construct date (longdate), it is used to calculate the millisecond difference between long seconds and January 1, 1970.

Given this millisecond, we can count the current year and the week, but that's not what we're going to calculate, because the final result of the Calendar.calendar is the date and time zone.

System.currenttimemillis () Gets the time distance from 1970-01-01 00:00:00.000 to the current moment, type long

String.valueof (System.currenttimemillis ()) This statement can be converted to a format:

Long ct = System.currenttimemillis ();

String t = string.valueof (CT);

In fact, the above string T is equivalent to ct+ "";

Knowledge to string format

Public String refformatnowdate () {

Date Nowtime = new Date (System.currenttimemillis ());

SimpleDateFormat sdformatter = new SimpleDateFormat ("Yyy-mm-dd");

String retstrformatnowdate = Sdformatter.format (nowtime);

return retstrformatnowdate;

}

Java get current system event 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.