java.time.ZonedDateTime.getZone() 方法示例



描述

java.time.ZonedDateTime.getZone() 方法獲取時區,如“歐洲/巴黎”。

宣告

以下是 java.time.ZonedDateTime.getZone() 方法的宣告。

public ZoneId getZone()

返回值

時區(非空)。

示例

以下示例展示了 java.time.ZonedDateTime.getZone() 方法的用法。

package com.tutorialspoint;

import java.time.ZonedDateTime;

public class ZonedDateTimeDemo {
   public static void main(String[] args) {
 
      ZonedDateTime date = ZonedDateTime.parse("2017-03-28T12:25:38.492+05:30[Asia/Calcutta]");
      System.out.println(date.getZone());  
   }
}

讓我們編譯並執行上述程式,將生成以下結果 −

Asia/Calcutta
廣告