java.time.Month.getValue() 方法示例



說明

java.time.Month.getValue() 方法獲取年中的月份整數值。

宣告

以下是 java.time.Month.getValue() 方法的宣告。

public int getValue()

返回值

年中月份,從 1(1 月)到 12(12 月)。

示例

以下示例演示瞭如何使用 java.time.Month.getValue() 方法。

package com.tutorialspoint;

import java.time.Month;

public class MonthDemo {
   public static void main(String[] args) {
 
      Month month = Month.FEBRUARY;
      System.out.println(month.getValue());  
   }
}

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

2
廣告
© . All rights reserved.