Java Date getYear() MethodThe 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:ParametersNA ReturnThe getYear() method returns the year represented by this date. ExampleTest it NowOutput: 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 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India