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

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

Description

get Day Of Month

License

Open Source License

Declaration

public static int getDayOfMonth(int month, int year) 

Method Source Code

//package com.java2s;

public class Main {

    public static int getDayOfMonth(int month, int year) {
        int days = 0;

        if (month == 2) {
            if (year % 4 != 0) {
                days = 28;//  www .  java2 s  .  co m
            } else {
                if (year % 100 == 0 && year % 400 != 0) {
                    days = 28;
                } else {
                    days = 29;
                }
            }

        } else {
            switch (month) {
            case 1:
                days = 31;
                break;
            case 3:
                days = 31;
                break;
            case 4:
                days = 30;
                break;
            case 5:
                days = 31;
                break;
            case 6:
                days = 30;
                break;
            case 7:
                days = 31;
                break;
            case 8:
                days = 31;
                break;
            case 9:
                days = 30;
                break;
            case 10:
                days = 31;
                break;
            case 11:
                days = 30;
                break;
            case 12:
                days = 31;
                break;
            default:
                break;
            }
        }

        return days;

    }
}

Related

  1. getDayMonth(String dayofmonth)
  2. getDayOfMonth(Date d)
  3. getDayOfMonth(Date date)
  4. getDayOfMonth(Date p_date)
  5. getDayOfMonth(int dayOfYear, boolean leap)
  6. getDayOfMonth(long time)
  7. getDayOfMonth(Object millis)
  8. GetDayOfMonth(String aDatetime)
  9. getDayOfMonth(String dateKey)