Java Leap Year Check LeapYear(String syear, String smonth, String sday)

Here you can find the source of LeapYear(String syear, String smonth, String sday)

Description

Leap Year

License

Open Source License

Declaration

public static String LeapYear(String syear, String smonth, String sday) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String LeapYear(String syear, String smonth, String sday) {
        long year = Long.parseLong(syear);
        long month = Long.parseLong(smonth);
        long day = Long.parseLong(sday);

        if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
            if (day == 31)
                day = 30;//  ww  w. j a v  a2 s  .  co  m
        } else if (month == 2) {
            if ((day == 31) || (day == 30) || (day == 29)) {
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                    day = 29;
                } else {
                    day = 28;
                }
            }
        }
        if (day < 10) {
            return "0" + String.valueOf(day);
        } else {
            return String.valueOf(day);
        }
    }

    public static long LeapYear(long year, long month, long day) {
        if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
            if (day == 31)
                day = 30;
        } else if (month == 2) {
            if ((day == 31) || (day == 30) || (day == 29)) {
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                    day = 29;
                } else {
                    day = 28;
                }
            }
        }
        return day;
    }
}

Related

  1. isLeapYear(String inputDate)
  2. LeapYear(int year)
  3. leapYear(int year)
  4. leapYear(int year)
  5. leapYear(int year)
  6. leapYearAdjustment(int year, int month)
  7. leapYearBalance(int yearInteger)