java clock计时
Clock Class systemDefaultZone()方法 (Clock Class systemDefaultZone() method)
systemDefaultZone() method is available in java.time package.
systemDefaultZone()方法在java.time包中可用。
systemDefaultZone() method is used to get the current instant that uses the system clock in the default zone.
systemDefaultZone()方法用于获取使用默认区域中的系统时钟的当前时刻。
systemDefaultZone() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
systemDefaultZone()方法是静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会收到错误。
systemDefaultZone() method does not throw an exception at the time of representing Clock.
systemDefaultZone()方法在表示Clock时不会引发异常。
Syntax:
句法:
public static Clock systemDefaultZone();
Parameter(s):
参数:
None
没有
Return value:
返回值:
The return type of this method is Clock, it returns the Clock object that uses the system clock in the default zone.
此方法的返回类型为Clock ,它返回使用默认区域中的系统时钟的Clock对象。
Example:
例:
// Java program to demonstrate the example
// of systemDefaultZone() method of Clock
import java.time.*;
public class SystemDefaultZoneOfClock {
public static void main(String args[]) {
// Instantiates two ZoneId for Accra
ZoneId zone_1 = ZoneId.of("Africa/Accra");
// Instantiates a clock for
// the given zone_1
Clock cl1 = Clock.system(zone_1);
// returns a Clock that is available in
// the system default zone
Clock sys_def_zone = cl1.systemDefaultZone();
System.out.println("cl1.systemDefaultZone(): " + sys_def_zone.toString());
sys_def_zone = Clock.systemDefaultZone();
System.out.println("Clock.systemDefaultZone(): " + sys_def_zone.toString());
}
}
Output
输出量
cl1.systemDefaultZone(): SystemClock[GMT]
Clock.systemDefaultZone(): SystemClock[GMT]
翻译自: https://www.includehelp.com/java/clock-systemdefaultzone-method-with-example.aspx
java clock计时