Year getValue() method in Java with Examples Last Updated : 01 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The getValue() method of Year class in Java is used to get the integral value of the current Year object. Syntax: public int getValue() Parameter: This method does not accepts any parameter. Return Value: It returns an integer denoting the value of the current year object. Below programs illustrate the getValue() method of Year in Java: Program 1: Java // Program to illustrate the getvalue() method import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class GfG { public static void main(String[] args) { // Creates a Year object Year firstYear = Year.of(1997); // Print the value of the current year // using getValue() method System.out.println(firstYear.getValue()); } } Output: 1997 Program 2: Java // Program to illustrate the getvalue() method import java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class GfG { public static void main(String[] args) { // Creates a Year object Year firstYear = Year.of(2018); // Print the value of the current year // using getValue() method System.out.println(firstYear.getValue()); } } Output: 2018 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#getValue-- Comment More infoAdvertise with us Next Article Year getValue() method in Java with Examples B barykrg Follow Improve Article Tags : Misc Java Java-Functions Java-time package Java-Year +1 More Practice Tags : JavaMisc Similar Reads Year get() method in Java with Examples get() method of the Year class used to get the value for the specified field passed as parameter from this Year as an integer value. This method queries this year for the value of the field and the returned value will always be within the valid range of values for the field. When the field is not su 2 min read Year getLong() method in Java with Examples getLong() method of the Year class used to gets the value as a long value from this Year for the specified field passed as parameter. This method queries this Year for the value of the field and the returned value will always be within the valid range of values for the field. When the field is not s 2 min read YearMonth get() method in Java with Examples The get() method of the YearMonth class in Java is used to get the value of the specified field from this year-month as an integer value. This method queries this year-month for the value of the specified field. The returned value will always be within the valid range. An exception is thrown if it i 2 min read Year hashCode() method in Java with Examples The hashCode() method of Year class in Java is used to get a suitable hash code for the current Year object. Syntax: public int hashCode() Parameter: This method does not accepts any parameter. Return Value: It returns a suitable integral hash code for the year object with which it is used. It never 1 min read YearMonth getLong() method in Java with Examples getLong() method of the YearMonth class in Java is used to get the value of the specified field from this year-month as a long value. This method queries this year-month for the value of the specified field. An exception is thrown if it is not possible to return the value because the field is not su 2 min read Like