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計時