java clock计时_Java Clock类| 带示例的getZone()方法

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计时

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值