java.time.Year.from(TemporalAmount amount)
方法从时间量获取Year
的实例。
声明
以下是java.time.Year.from(TemporalAmount amount)
方法的声明。
public static Year from(TemporalAmount amount)
参数
amount
- 要转换的时间量,而不是null
。
返回值
等效年份,不为null
。
例外
DateTimeException
- 如果无法转换为Year
。ArithmeticException
- 如果发生数字溢出。
示例
以下示例显示了java.time.Year.from(TemporalAmount amount)
方法的用法。
package com.zaixian;
import java.time.Year;
public class YearDemo {
public static void main(String[] args) {
Year date = Year.from(Year.of(2017));
System.out.println(date);
}
}
编译并运行上面的程序,这将产生以下结果 -
2017
上一篇:
java.time.Year类
下一篇:
java.time.YearMonth类