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) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month - 1);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        int value = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        cal.set(Calendar.DAY_OF_MONTH, value);
        StringBuffer sb = new StringBuffer();
        String date = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
        sb.append(date).append(" 23:59");
        return sb.toString();

    }/*from   w ww  .  java  2s .co  m*/
}

Related

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