I am following \"The Art and Science of Java\" book and it shows how to calculate a leap year. The book uses ACM Java Task Force\'s library.
Here is the code the boo
From JAVA's GregorianCalendar sourcecode:
/**
* Returns true if {@code year} is a leap year.
*/
public boolean isLeapYear(int year) {
if (year > changeYear) {
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
}
return year % 4 == 0;
}
Where changeYear is the year the Julian Calendar becomes the Gregorian Calendar (1582).
The Julian calendar specifies leap years every four years, whereas the Gregorian calendar omits century years which are not divisible by 400.
In the Gregorian Calendar documentation you can found more information about it.