Here you can find the source of getDaysByWeek(Integer month, Integer year, Integer week)
public static Integer getDaysByWeek(Integer month, Integer year, Integer week)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.HashMap; import java.util.Map; public class Main { public static Integer getDaysByWeek(Integer month, Integer year, Integer week) { Integer num = null;/*w ww . ja v a2 s .c om*/ Calendar c = Calendar.getInstance(); c.set(year, month - 1, 1); int mountDay = c.getActualMaximum(Calendar.DAY_OF_MONTH); num = mountDay / 7; int yu = mountDay % 7; for (int i = 1; i <= yu; i++) { c.set(Calendar.DAY_OF_MONTH, i); if (week == c.get(Calendar.DAY_OF_WEEK)) { num++; break; } } return num; } public static Map<Integer, Integer> getDaysByWeek(Integer month, Integer year) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); Integer num = null; Calendar c = Calendar.getInstance(); c.set(year, month - 1, 1); int mountDay = c.getActualMaximum(Calendar.DAY_OF_MONTH); num = mountDay / 7; int yu = mountDay % 7; for (int j = 1; j <= 7; j++) { for (int i = 1; i <= yu; i++) { c.set(Calendar.DAY_OF_MONTH, i); map.put(j, num); if (j == c.get(Calendar.DAY_OF_WEEK)) { map.put(j, num + 1); break; } } } return map; } }