Java Day in Month getMonthDays(int year, int month)

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

Description

get Month Days

License

Open Source License

Declaration

public static int getMonthDays(int year, int month) 

Method Source Code

//package com.java2s;

public class Main {
    public static int getMonthDays(int year, int month) {
        switch (month) {
        case 1:/*from  w  w w  .  j  av  a2 s .c  o m*/
            return 31;
        case 2:
            if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
                return 29;
            } else {
                return 28;
            }
        case 3:
            return 31;
        case 4:
            return 30;
        case 5:
            return 31;
        case 6:
            return 30;
        case 7:
            return 31;
        case 8:
            return 31;
        case 9:
            return 30;
        case 10:
            return 31;
        case 11:
            return 30;
        case 12:
            return 31;
        default:
            return 0;
        }
    }
}

Related

  1. getLastDayOfMonth(String monthInitials)
  2. getMaxDayByMonth(String month)
  3. getMaxMonthDay(int year, int month)
  4. getMonthDay(int year, int month)
  5. getMonthDayFormats()
  6. getMonthDaysArray(int year)
  7. getMonthDayString(long l, boolean timezone, boolean formated)
  8. getMonthlyCronExpression(int minutes, int hours, int dayOfMonth)
  9. getMonthOfDayMark(int day)