Java Month of Year getMaxDayOfMonth(int year, int month)

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

Description

get Max Day Of Month

License

Open Source License

Declaration

public static int getMaxDayOfMonth(int year, int month) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

import java.util.GregorianCalendar;

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

    public static int getMaxDayOfMonth(int year, int month) {
        if (month == 1 && isLeapYear(year)) {
            return 29;
        }/*from w ww  . j a  va  2  s.  c  o m*/
        return DAY_OF_MONTH[month];
    }

    public static boolean isLeapYear(int year) {
        Calendar calendar = Calendar.getInstance();
        return ((GregorianCalendar) calendar).isLeapYear(year);
    }
}

Related

  1. getLastMonthdate()
  2. getLastMonthDate()
  3. getLastMonthDate(int date)
  4. getLastMonthOfQuater(Date date)
  5. getLastMonthOfYear()
  6. getMonth(int week, int year)
  7. getMonthDays(Object year, Object month)
  8. getMonthHaveDays(int year, int month)
  9. getMonthOfYear(int m)