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



說明

java.time.ZonedDateTime.getMonth() 方法使用 Month 列舉獲取月份欄位。

宣告

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

public Month getMonth()

返回值

月份,非 null。

示例

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

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.getMonth());  
   }
}

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

MARCH
廣告