Java get Year
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
import java.util.*;
|
Output will be displayed as: