GregorianCalendar.isLeapYear(int year) has the following syntax.
public boolean isLeapYear(int year)
In the following code shows how to use GregorianCalendar.isLeapYear(int year) method.
/* w ww.j a v a 2s .co m*/ import java.util.*; public class Main { public static void main(String[] args) { GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); // check if it is a leap year boolean isLeapYear = cal.isLeapYear(cal.get(GregorianCalendar.YEAR)); System.out.println("Is leap year:" + isLeapYear); // check if 2014 is a leap year isLeapYear = cal.isLeapYear(2014); System.out.println("Is leap year:" + isLeapYear); } }
The code above generates the following result.