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.