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

Apache License

Declaration

public static String getLastDayOfMonth(int year, int month) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static final String FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getLastDayOfMonth(int year, int month) {
        Calendar c = Calendar.getInstance();
        c.set(year, month, 1, 0, 0, 0);//from www . ja v  a  2s  . com
        c.add(Calendar.MONTH, -1);
        c.set(Calendar.DAY_OF_MONTH, c.getMaximum(Calendar.DAY_OF_MONTH));
        SimpleDateFormat sdf = new SimpleDateFormat(FORMAT);
        return sdf.format(c.getTime());
    }
}

Related

  1. getLastDayOfMonth(Date now)
  2. getLastDayOfMonth(Date sDate)
  3. getLastDayOfMonth(final Date date)
  4. getLastdayOfMonth(int month, int year)
  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(int year, int month)