Here you can find the source of getLastDayOfMonth()
public static String getLastDayOfMonth()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); public static String getLastDayOfMonth() { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); final int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); Date lastDate = calendar.getTime(); lastDate.setDate(lastDay);/*from w w w. ja v a 2s . co m*/ return sdf2.format(lastDate); } }