Here you can find the source of getDaysByYearMonth(String ym)
public static List<String> getDaysByYearMonth(String ym)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; public class Main { public static List<String> getDaysByYearMonth(String ym) { List<String> list = new ArrayList<String>(); int maxDate = getMaxDayByYearMonth(ym); for (int i = 1; i <= maxDate; i++) { String d = String.valueOf(i < 10 ? "0" + i : i); list.add(ym + "-" + d); }/*from w w w. j ava2s . c o m*/ return list; } public static int getMaxDayByYearMonth(String ym) { int day = 0; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); Calendar calendar = new GregorianCalendar(); Date date = sdf.parse(ym); calendar.setTime(date); day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); } catch (ParseException e) { day = 0; } return day; } }