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 ().