Java Month of Year daysInMonth(final int year, final int month)

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

Description

Get the number of days in that month.

License

Open Source License

Parameter

Parameter Description
year Year.
month Month.

Return

Number of days in month.

Declaration

public static int daysInMonth(final int year, final int month) 

Method Source Code

//package com.java2s;
// and/or modify it under the terms of the GNU General Public License 

import java.util.Calendar;

public class Main {
    /**//from   w  ww .  j a  va2s .co m
     * Get the number of days in that month.
     * 
     * @param year
     *            Year.
     * @param month
     *            Month.
     * @return Number of days in month.
     */
    public static int daysInMonth(final int year, final int month) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, 1);
        return cal.getActualMaximum(Calendar.DAY_OF_MONTH);
    }
}

Related

  1. createTimestamp(int year, int month, int day, int hour, int minutes, int seconds)
  2. currentYearMonth()
  3. dayOfYear(int year, int month, int day)
  4. dayOfYear(int year, int month, int day)
  5. daysInMonth(final int month, final int year)
  6. daysInMonth(int month, int year)
  7. daysInMonth(int month, int year)
  8. daysInMonth(int year, int month)
  9. daysInMonth(int year, int month)