java clock计时
Clock Class getZone()方法 (Clock Class getZone() method)
getZone() method is available in java.time package.
getZone()方法在java.time包中可用。
getZone() method is used to get the time zone that is linked with this Clock.
getZone()方法用于获取与此Clock关联的时区。
getZone() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.
getZone()方法是一种非静态方法,可通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
getZone() method does not throw an exception at the time of getting time zone.
getZone()方法在获取时区时不会引发异常。
Syntax:
句法:
public abstract ZoneId getZone();
Parameter(s):
参数:
None
没有
Return value:
返回值:
The return type of this method is ZoneId, it returns the time zone that is used to represent with this Clock.
此方法的返回类型为ZoneId ,它返回用于表示此Clock的时区。
Example:
例:
// Java program to demonstrate the example
// of getZone() method of Clock
import java.time.*;
public class GetZoneOfClock {
public static void main(String args[]) {
// Initialize two Clock objects
Clock cl1 = Clock.systemDefaultZone();
Clock cl2 = Clock.systemUTC();
// returns the time-zone of this
// Clock cl1
ZoneId cl1_zone = cl1.getZone();
// Display cl1 zone
System.out.println("cl1.getZone(): " + cl1_zone);
// returns the time-zone of this
// Clock cl2
ZoneId cl2_zone = cl2.getZone();
// Display cl2 zone
System.out.println("cl2.getZone(): " + cl2_zone);
}
}
Output
输出量
cl1.getZone(): GMT
cl2.getZone(): Z
翻译自: https://www.includehelp.com/java/clock-getzone-method-with-example.aspx
java clock计时