Java Day in Month getDaysInMonth(int monthNum)

Here you can find the source of getDaysInMonth(int monthNum)

Description

get Days In Month

License

Apache License

Declaration

public static int getDaysInMonth(int monthNum) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    final static int DOM[] = { 31, 28, 31, 30, /* jan feb mar apr */
            31, 30, 31, 31, /* may jun jul aug */
            30, 31, 30, 31 /* sep oct nov dec */
    };//from  w  ww  .java2  s  .c  o m

    public static int getDaysInMonth(int monthNum) {
        if (monthNum < 0) {
            throw new IllegalArgumentException("Month number must be non-negative");
        }
        if (monthNum >= 12) {
            throw new IndexOutOfBoundsException("There are 12 months in a year, so monthNum must be in 0..11");
        }
        return DOM[monthNum];
    }
}

Related

  1. getDayOfMonthSuffix(final int day)
  2. getDayOrMonth(int value)
  3. getDaysByMonth(int month)
  4. getDaysInMonth(int month, int year)
  5. getDaysInMonth(int month, int year)
  6. getDaysInMonth(int year, int month)
  7. getDaysInMonths()
  8. getDaysOfMonth(Date startdate, Date enddate, String month)
  9. getFirstDayOfMonth(int year, int month)