目录

int getMonthValue()

描述 (Description)

java.time.YearMonth.getMonthValue()方法获取1到12之间的月份字段。

声明 (Declaration)

以下是java.time.YearMonth.getMonthValue()方法的声明。

public int getMonthValue()

返回值 (Return Value)

月份,从1到12。

例子 (Example)

以下示例显示了java.time.YearMonth.getMonthValue()方法的用法。

package com.iowiki;
import java.time.YearMonth;
public class YearMonthDemo {
   public static void main(String[] args) {
      YearMonth date = YearMonth.of(2017,12);
      System.out.println(date.getMonthValue());  
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

12
↑回到顶部↑
WIKI教程 @2018