java.time.Year.isBefore(Year other)
方法检查此年份是否在指定年份之前。
声明
以下是java.time.Year.isBefore(Year other)
方法的声明。
public boolean isBefore(Year other)
参数
other
- 与另一年份进行比较,不能为null
。
返回值
如果此年份在指定年份之前,则为true
。
示例
以下示例显示了java.time.Year.isBefore(Year other)
方法的用法。
package com.zaixian;
import java.time.Year;
public class YearDemo {
public static void main(String[] args) {
Year date = Year.of(2016);
Year date1 = Year.of(2017);
System.out.println(date1.isBefore(date));
}
}
编译并运行上面的程序,这将产生以下结果 -
false
上一篇:
java.time.Year类
下一篇:
java.time.YearMonth类