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