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) { 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()); } }