001package de.hdm_stuttgart.sd1.leap;
002
003/**
004 * Leap year calculations
005 *
006 */
007public class LeapYearCompact {
008
009  /**
010   * @param args unused
011   */
012  public static void main(final String[] args) {
013    System.out.println("Is 1800 a leap year? " + isLeapYear(1800));
014    System.out.println("Is 2000 a leap year? " + isLeapYear(2000));
015    System.out.println("Is 2016 a leap year? " + isLeapYear(2016));
016  }
017
018  /**
019   * Characterizing a given year either as leap year or
020   * non- leap year.
021   *
022   * Syntactically different implementation with regard to {@link LeapYear} having
023   * identical logic.
024   * 
025   * @param year The year in question.
026   * @return true if year is a leap year, false otherwise.
027   */
028  public static boolean isLeapYear(final int year) {
029    return
030        year % 400 == 0 ||                  // Every 400 years we do have a leap year.
031        year % 4 == 0 &&  0 != year % 100;  // Every 4 years we do have a leap year unless the year
032                                            // in question is a multiple of 100.
033  }  
034}