Last Updated : 27 Nov, 2018
The isLeap() method of Year class in Java is used to check if this Year object is a leap year or not according to the proleptic calendar system rules. A year is a
leap yearif it has 366 days in it. According to the proleptic calendar system rules, a year is a Leap year if:
:
public boolean isLeap()Parameter
: This method does not accepts any parameter.
Return Value: It returns a boolean True value if this Year object's value is a leap year according to the proleptic calendar system rules, otherwise it returns False. Below programs illustrate the isLeap() method of Year in Java:
Program 1:
Java
// Program to illustrate the isLeap() method
import java.util.*;
import java.time.*;
public class GfG {
public static void main(String[] args)
{
// Create first Year object
Year firstYear = Year.of(2016);
// Check if this year object's value is
// a leap year or not
System.out.println(firstYear.isLeap());
}
}
Program 2
:
Java
// Program to illustrate the isLeap() method
import java.util.*;
import java.time.*;
public class GfG {
public static void main(String[] args)
{
// Create first Year object
Year firstYear = Year.of(1990);
// Check if this year object's value is
// a leap year or not
System.out.println(firstYear.isLeap());
}
}
Reference
:
https://docs.oracle.com/javase/8/docs/api/java/time/Year.html#isLeap--RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4