Here you can find the source of getLastDateOfCurMonth()
public static String getLastDateOfCurMonth()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static final String date_pattern = "yyyy-MM-dd"; public static String getLastDateOfCurMonth() { String curYearMonth = getCurYearMonth(); Calendar calendar = Calendar.getInstance(); int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); return curYearMonth + "-" + maxDay; }/* w w w . j a va2 s . c o m*/ public static String getCurYearMonth() { String curTime = getCurDate(); String curYearMonth = curTime.substring(0, 7); return curYearMonth; } public static String getCurDate() { Date date = new Date(); SimpleDateFormat format = new SimpleDateFormat(date_pattern); return format.format(date); } public static String getCurDate(String fmt) { Date date = new Date(); SimpleDateFormat format = new SimpleDateFormat(fmt); return format.format(date); } }