In this section, you will learn how to obtain the current year. The Calendar class provides a getInstance() method that returns a Calendar object. The method cal.get(Calendar.YEAR) will return the current year.
Here is the code of GetYear.java
Output will be displayed as:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.