173
Java Date getYear() Method
The getYear() method of Java date class returns the value by subtracting 1900 from the year that contains or begin with an instant in time which is represented by this date object as interpreted in local time zone.
This method is deprecated as of JDK version 1.1 and replaced by Calendar.get(Calendar.YEAR)
Syntax:
Parameters
NA
Return
The getYear() method returns the year represented by this date.
Example
Output:
Year for date object is : 118 ***To get current year add 1900 to the value of year obtained from this date object*** Current year is : 2018
Next TopicJava Util Date