目录

Year plus(TemporalAmount amountToAdd)

描述 (Description)

java.time.Year.plus(TemporalAmount amountToAdd)方法返回此Year的副本,并添加了指定的Year。

声明 (Declaration)

以下是java.time.Year.plus(TemporalAmount amountToAdd)方法的声明。

public Year plus(TemporalAmount amountToAdd)

参数 (Parameters)

amountToAdd - 要添加的年份,正面或负面,不为空。

返回值 (Return Value)

基于此年份添加指定年份的年份,不为空。

异常 (Exception)

  • DateTimeException - 如果指定的数量具有非ISO年表或包含无效单位。

  • ArithmeticException - 如果发生数字溢出。

例子 (Example)

以下示例显示了java.time.Year.plus(TemporalAmount amountToAdd)方法的用法。

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

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

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