Determining the number of days in a month of a particular year

This small example looks only at the days of february of the last 20 years.

Main.java:

import java.util.*;
 
public class Main
{
   public static void main(String []args) {
      for (int i=1980; i<2010; i++) {
         Calendar calendar = new GregorianCalendar(i, Calendar.FEBRUARY, 1);
 
         int numberOfDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
 
         System.out.println("February " + i + ": " + numberOfDays + " days");
      }
   }
} 

outputs:

February 1980: 29 days
February 1981: 28 days
February 1982: 28 days
February 1983: 28 days
February 1984: 29 days
February 1985: 28 days
February 1986: 28 days
February 1987: 28 days
February 1988: 29 days
February 1989: 28 days
February 1990: 28 days
February 1991: 28 days
February 1992: 29 days
February 1993: 28 days
February 1994: 28 days
February 1995: 28 days
February 1996: 29 days
February 1997: 28 days
February 1998: 28 days
February 1999: 28 days
February 2000: 29 days
February 2001: 28 days
February 2002: 28 days
February 2003: 28 days
February 2004: 29 days
February 2005: 28 days
February 2006: 28 days
February 2007: 28 days
February 2008: 29 days
February 2009: 28 days