Java Year From getYearMonthDays(int year, int month)

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

Description

get Year Month Days

License

Apache License

Declaration

public static int getYearMonthDays(int year, int month) 

Method Source Code

//package com.java2s;
/*//  w  ww . j ava  2  s  . com
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {

    public static int getYearMonthDays(int year, int month) {
        int days = 31;
        switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            days = 31;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            days = 30;
            break;
        case 2:
            if (year % 4 == 0 || year % 100 == 0 || year % 400 == 0) {
                days = 29;
                break;
            }
            days = 28;
            break;
        }
        return days;
    }
}

Related

  1. getYearFromTimestamp(long ms)
  2. getYearFromWeekCode(String weekCode)
  3. getYearFromYM(String ym)
  4. getYearMonth(String day)
  5. getYearMonthArray(Integer yearMonth)
  6. getYearNumberofdays(String date)
  7. getYearOfDayMark(int day)
  8. getYearOfPreYearWeek(int year, int week)
  9. getYearOfTime(Long time)