Java Day of Month getLastDayOfMonth(int year, int month)

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

Description

get Last Day Of Month

License

Open Source License

Declaration

public static int getLastDayOfMonth(int year, int month) 

Method Source Code

//package com.java2s;

import java.util.Calendar;

public class Main {

    public static int getLastDayOfMonth(int year, int month) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month - 1);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        int value = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH, value);
        return calendar.get(Calendar.DAY_OF_MONTH);
    }/*from  w w  w . j  ava 2 s. c  om*/
}

Related

  1. getLastDayOfMonth(int year, int month)
  2. getLastDayOfMonth(int year, int month)
  3. getLastDayOfMonth(int year, int month)
  4. getLastDayOfMonth(int year, int month)
  5. getLastDayOfMonth(int year, int month)
  6. getLastDayOfMonth(java.util.Date date)
  7. getLastDayOfMonth(String year, String month)
  8. getLastDayOfMonth(String year, String month)
  9. getLastdayOfMonth(String year, String month)