Here you can find the source of getLastDayOfMonth(int year, int month)
public static String getLastDayOfMonth(int year, int month)
//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*/ }