GregorianCalendar class isLeapYear(int year)method example

Determines if the given year is a leap year.


GregorianCalendarclass isLeapYear(int year)method example. This example shows you how to use isLeapYear(int year) method.This method Determines if the given year is a leap year.

Here is the code:-

/**
 * @Program that Determines if the given year is a leap year.
 * IsLeapYear.java 
 * Author:-RoseIndia Team
 * Date:-27-May-2008
 */
import java.util.*;

public class IsLeapYear {

    public static void main(String[] args) {//Creating a Calendar    
        GregorianCalendar g = new GregorianCalendar(200463);
//Displays the date of the Calendar
        System.out.println("Current Year of the Calendar is: "
                + g.get(Calendar.YEAR));
//Determines if the given year is a leap year
        boolean b = g.isLeapYear(2008);
        System.out.println("LeapYear : " + b);
//Determines if the given year is a leap year
        boolean b1 = g.isLeapYear(2009);
        System.out.println("LeapYear : " + b1);
    }
}

  Output of the program:-
Current Year of the Calendar is: 2004
LeapYear : true
LeapYear : false

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US