1.System class Acquisition
At the current time , the System class cannot be instantiated and needs to be called through its static method.
Use the System class Currenttimemillis () method to get the current system time. Returns the time in milliseconds, and the granularity of the value depends on the underlying operating system.
Public Static long Currenttimemillis ()
Return value type: Long
long currenttime = system.currenttimemillis (); System.out.println (currenttime);
2.Date class
The class Date represents a specific instantaneous, accurate to milliseconds.
How to construct the Date class
| Format |
Parameter list |
Description |
| Date () |
Null parameter |
Gets an object that represents the current system time |
| Date (long date) |
An integer of type long, in milliseconds of absolute time |
|
Null parameter gets the current time, specifying a long integer to get the time point corresponding to the integer
SYSTEM.OUT.PRINTLN (new// Print current system time System.out.println (new// Print absolute time 0 point in time information System.out.println (new// Print absolute time the day before the point information
A
Time in Java