tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Commons > Is Leap Year

Is Leap Year 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use TimeUtil.isLeapYear() API. It checks whether the given year is a leap year.

File Name  :  
com/bethecoder/tutorials/jodd/time/IsLeapYearTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jodd.time;

import jodd.datetime.TimeUtil;

public class IsLeapYearTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    int year = 1982;
    boolean leapYear = TimeUtil.isLeapYear(year);
    System.out.println(year + " is " (leapYear ? "Leap" "Non-Leap"" Year");
    
    year = 2000;
    leapYear = TimeUtil.isLeapYear(year);
    System.out.println(year + " is " (leapYear ? "Leap" "Non-Leap"" Year");
    
    year = 2012;
    leapYear = TimeUtil.isLeapYear(year);
    System.out.println(year + " is " (leapYear ? "Leap" "Non-Leap"" Year");
  }

}
   

It gives the following output,
1982 is Non-Leap Year
2000 is Leap Year
2012 is Leap Year



 
  


  
bl  br