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