Java Month getMonthLength(int year, int month)

Here you can find the source of getMonthLength(int year, int month)

Description

get Month Length

License

Open Source License

Declaration

private static int getMonthLength(int year, int month) 

Method Source Code

//package com.java2s;

public class Main {
    private static final int[] teMl = new int[] { 0, 31, 28, 31, 30, 31,
            30, 31, 31, 30, 31, 30, 31 };

    private static int getMonthLength(int year, int month) {
        int ml;//from   w w w  .ja  va 2  s . co  m
        if ((month == 2) && (isLeapYear(year))) {
            ml = 29;
        } else {
            ml = teMl[month];
        }
        return (ml);
    }

    private static boolean isLeapYear(int year) {
        // This is the Gregorian Calendar
        return ((year % 400) == 0)
                || (((year % 4) == 0) && ((year % 100) != 0));
    }
}

Related

  1. getMonthFromYM(String ym)
  2. getMonthInEnglish(int month)
  3. getMonthLastDate(int month, int year)
  4. getMonthLength(final int year, final int month)
  5. getMonthLength(int year, int m)
  6. getMonthMaxDate(String str)
  7. getMonthOfNextQuarter(String yearAndMonth)
  8. getMonthRange(String start, String end)
  9. getMonths()