java.time.ZonedDateTime.getMonthValue() 方法
描述
java.time.ZonedDateTime.getMonthValue() 方法获取从 1 到 12 的月份字段。
声明
以下是 java.time.ZonedDateTime.getMonthValue() 方法的声明。
public int getMonthValue()
返回值
一年中的月份,从 1 到 12。
示例
下面的例子展示了 java.time.ZonedDateTime.getMonthValue() 方法的使用。
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

