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 String getLastDayOfMonth(int year, int month) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

    public static String getLastDayOfMonth(int year, int month) {
        int m = month;
        if (m > 12)
            m = 12;//w ww . j ava 2 s  . co m
        if (m < 1)
            m = 1;

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, m - 1);
        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE));
        return new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
    }
}

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(int year, int month)
  7. getLastDayOfMonth(int year, int month)
  8. getLastDayOfMonth(java.util.Date date)
  9. getLastDayOfMonth(String year, String month)