The current time is obtained by system. currenttimemillis ().

Source: Internet
Author: User

 

The system class represents the system. Many system-level attributes and control methods are placed inside the class. This class is located in the Java. lang package.

Currenttimemillis Method

Public static long currenttimemillis ()

The function of this method is to return the current computer time. The expression format of time is the number of milliseconds between the current computer time and GMT time (Greenwich Mean Time) 00:00:00, January 1, January 1, 1970.

You can directly convert this method to the date type.

The Code is as follows:

Long currenttime = system. currenttimemillis (); simpledateformat formatter = new simpledateformat ("yyyy-mm DD-hh mm minutes SS seconds"); Date = new date (currenttime); system. out. println (formatter. format (date ));

The running result is as follows:

Current Time: 2011-August 10-14

In addition:

You can obtain the current system and user attributes:

String osname = system. getproperty ("OS. Name ");

String user = system. getproperty ("user. Name ");

System. Out. println ("the current operating system is:" + osname );

System. Out. println ("the current user is:" + User );

The system. getproperty method can obtain many system attributes.

 

From: http://blog.csdn.net/mywebstudy/article/details/7814695

 

The current time is obtained by 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.