java.time.YearMonth.now() 方法
描述
java.time.YearMonth.now() 方法从默认时区的系统时钟中获取当前的年月。
声明
以下是 java.time.YearMonth.now() 方法的声明。
public static YearMonth now()
返回值
使用系统时钟和默认时区的当前年份月份,不为空。
示例
下面的例子展示了 java.time.YearMonth.now() 方法的使用。
package com.tutorialspoint;
import java.time.YearMonth;
public class YearMonthDemo {
public static void main(String[] args) {
YearMonth date = YearMonth.now();
System.out.println(date);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
2017-03

