Java Day in Month daysInMonth(int month, boolean isLeapYear)

Here you can find the source of daysInMonth(int month, boolean isLeapYear)

Description

days In Month

License

Open Source License

Declaration

static int daysInMonth(int month, boolean isLeapYear) 

Method Source Code

//package com.java2s;
// (c) 2012 B Smith-Mannschott -- Distributed under the Eclipse Public License

public class Main {
    private static final byte[] DAYS_IN_MONTH = { 31, 28, 31, 30, 31, 30,
            31, 31, 30, 31, 30, 31, // non-leap-year
            31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, // leap year
    };

    static int daysInMonth(int month, boolean isLeapYear) {
        int i = (month - 1) + 12 * (isLeapYear ? 1 : 0);
        return DAYS_IN_MONTH[i];
    }/*from w w w .j a v  a  2  s.c  om*/
}

Related

  1. currentMonthFirstDay()
  2. dayForMonth(String pTime)
  3. daysInMonth(int month, int year)
  4. daysInMonth(int year, int month)
  5. daysOfMonth(int year)
  6. daysOfMonth(int year, int month)