Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Clock clock class in Java8

Shulou Source: shulou.com Published: 2022-06-01 02:14:05 10月03日 Update

This article mainly shows you "how to use the Clock clock class in Java8", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to use the Clock clock class in Java8".

Clock clock class of Java 8

Java 8 adds a Clock clock class to get the current timestamp, or date-time information under the current time zone. Places where System.currentTimeInMillis () and TimeZone.getDefault () were previously used can be replaced with Clock.

Package com.shxt.demo02; import java.time.Clock; public class Demo10 {public static void main (String [] args) {/ / Returns the current time based on your system clock and set to UTC. Clock clock = Clock.systemUTC (); System.out.println ("Clock:" + clock.millis ()); / / Returns time based on system clock zone Clock defaultClock = Clock.systemDefaultZone (); System.out.println ("Clock:" + defaultClock.millis ());}} above is all the content of this article "how to use Clock clock in Java8". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Clock content article time learning help information place date time zone easy to understand more organization knowledge editing industry information information channels channels research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Redmi Huawei Microsoft