Here you can find the source of getLastDayOfTheMonth(String dateOfString)
public static int getLastDayOfTheMonth(String dateOfString)
//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 int getLastDayOfTheMonth(String dateOfString) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MM"); Date date = null;//from w ww . j a v a2 s . c o m try { date = yearMonthFormat.parse(dateOfString); } catch (ParseException e) { e.printStackTrace(); } calendar.setTime(date); final int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); return lastDay; } }