Determining If a Year Is a Leap Year

GregorianCalendar cal = new GregorianCalendar(); boolean b = cal.isLeapYear(1998); // false b = cal.isLeapYear(2000); // true b = cal.isLeapYear(0); // true

Comments

14 Aug 2010 - 12:19am by Anonymous (not verified)

class leap
{
public static void main(String[] args)
{
int year=2012;

{
if(year%4==0)

System.out.println("year is leap");
else

System.out.println("year is not leap");
}
}
}

24 Aug 2010 - 6:01am by Anonymous (not verified)

The algorithm listed in the previous comment is *not* correct for determining leap years, at least for the Gregorian calendar, i.e. the calendar recognized internationally.

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.