Here you can find the source of getMaxDayOfYearMonth(String date)
public static String getMaxDayOfYearMonth(String date)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getMaxDayOfYearMonth(String date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); try {/*from w ww.ja va 2s . co m*/ Date d = sdf.parse(date); Calendar calendar = Calendar.getInstance(); calendar.setTime(d); int lastDayNum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); date = date + "-" + lastDayNum; } catch (ParseException e) { e.printStackTrace(); } return date; } }