The java.util.GregorianCalendar.isLeapYear() method determines if the given year passed as a parameter to the function is a leap year or not and returns true if the given year is a leap year and false otherwise.
public boolean isLeapYear(int year)
Parameters: This function accepts a single integer parameter year that represents the year which the function needs to check for whether it is a leap year or not.
Return Values: The function returns a boolean value. If the year passed as a parameter is a leap year, it returns true and false otherwise.
Input : 2016 Output : true Input : 2018 Output : false
Below program illustrate the java.util.GregorianCalendar.isLeapYear() function in Java :
Current Date and Time : Fri Jul 27 11:53:39 UTC 2018 2018 is Not a leap year
Fri Jul 27 11:53:41 UTC 2018 2016 is leap year
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.