目录

Year plusYears(long yearsToAdd)

描述 (Description)

java.time.Year.plusYears(long years)方法返回指定年份的本年份副本。

声明 (Declaration)

以下是java.time.Year.plusYears(long years)方法的声明。

public Year plusYears(long years)

参数 (Parameters)

years - 添加的年份,正面或负面。

返回值 (Return Value)

基于本年度的年份,添加了指定年份,不为空。

异常 (Exception)

ArithmeticException - 如果发生数字溢出。

例子 (Example)

以下示例显示了java.time.Year.plusYears(long years)方法的用法。

package com.iowiki;
import java.time.Year;
public class YearDemo {
   public static void main(String[] args) {
      Year date = Year.parse("2017");
      Year date1 = date.plusYears(10);
      System.out.println(date1);   
   }
}

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

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