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

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

Description

Returns the number of days in the provided month and year.

License

Open Source License

Parameter

Parameter Description
year a parameter
month a parameter

Return

number of days in month

Declaration

public static int getNumberOfDays(int year, int month) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    /**/*from  www  .  j  a  v a2s . com*/
     * Returns the number of days in the provided month and year.
     * @param year
     * @param month
     * @return number of days in month
     */
    public static int getNumberOfDays(int year, int month) {
        Calendar calendar = new GregorianCalendar(year, month, 1);
        return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); // 28
    }
}

Related

  1. getNextMonthFirstDay(String date)
  2. getNextMonthFirstDay(T day)
  3. getNextMonthFistDay(String nowdate, String inFormat, String outFormat)
  4. getNextYearMonth(String yearMonth)
  5. getNrDaysOfMonth(int month, int year)
  6. getOntologyURIBase(String defaultBase, boolean appendYear, boolean appendMonth, boolean appendDay)
  7. getPreviousDateStringByMonth(int months)
  8. getPreviousDay(int year, int month, int day, int days)
  9. getPrevMonth(String divisionDate, int day, String outputFormat)