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.