Description
1. Clock provides access to the current date and time. In System.currentTimeMillis() method we can use it.
2. You can also obtain an instant instance through clock.instant(). This instance can be easily converted to an old version of java.util.Date object.
Example
Clock clock = Clock.systemDefaultZone(); long millis = clock.millis(); Instant instant = clock.instant(); Date legacyDate = Date.from(instant); // 老版本 java.util.Date
1. Simple, just understand the basic concepts, you can write programs suitable for various situations Application;
2. Object-oriented;
3. Distribution, Java is a network-oriented language;
4. Robustness, java provides automatic garbage collection To perform memory management and prevent programmers from making errors when managing memory;
5. Security, Java used in network and distributed environments must prevent virus intrusion.
6. Architecture neutral, as long as the Java runtime system is installed, it can run on any processor.
7. Portability, Java can be easily transplanted to different machines on the network.
8. Interpretation and execution, the Java interpreter directly interprets and executes the Java bytecode.
The above is the detailed content of How to access time in java Clock. For more information, please follow other related articles on the PHP Chinese website!