Here you can find the source of getMonthMaxDay(String sDate)
private static String getMonthMaxDay(String sDate)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { private static String getMonthMaxDay(String sDate) { SimpleDateFormat sdf_full = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); Date date = null;/*from w w w .j a v a 2s .c o m*/ try { date = sdf_full.parse(sDate + "-01"); } catch (ParseException e) { e.printStackTrace(); } cal.setTime(date); int last = cal.getActualMaximum(Calendar.DATE); return String.valueOf(last); } }