Here you can find the source of getDaysForDate(String date)
public static int getDaysForDate(String date)
//package com.java2s; //License from project: Open Source License import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static int getDaysForDate(String date) { Date curDate = strToDate(date); Calendar calendar = Calendar.getInstance(); calendar.setTime(curDate);// w ww . ja va 2 s . co m return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); } public static Date strToDate(String strDate) { return strToDate(strDate, "yyyy-MM-dd"); } public static Date strToDate(String strDate, String format) { if (strDate == null) { return null; } SimpleDateFormat formatter = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); Date strtodate = formatter.parse(strDate, pos); return strtodate; } }