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



描述

java.time.ZonedDateTime.getMonthValue() 方法獲取 1 到 12 之間的年份月份欄位。

宣告

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

public int getMonthValue()

int getMonthValue()

返回值

1 到 12 之間的年份月份。

示例

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

現場演示

3
列印頁面