java.time.Year.getValue() 方法示例



描述

java.time.Year.getValue() 方法获取年份值。

声明

以下是 java.time.Year.getValue() 方法的声明。

public int getValue()

返回值

年份,从 MIN_YEAR 到 MAX_YEAR。

示例

以下示例演示了 java.time.Year.getValue() 方法的用法。

package com.tutorialspoint;

import java.time.Year;

public class YearDemo {
   public static void main(String[] args) {
 
      Year date = Year.of(2017);
      System.out.println(date.getValue());  
   }
}

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

2017
广告
© . All rights reserved.