Here you can find the source of getWorkDayNum(int year, int month, int start, int end)
public static Map<Integer, Integer> getWorkDayNum(int year, int month, int start, int end)
//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 Map<Integer, Integer> getWorkDayNum(int year, int month, int start, int end) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); if (start != end) { for (int i = start; i <= end; i++) { Calendar c = Calendar.getInstance(); c.set(year, month - 1, i); if (1 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(1) == null ? 0 : map.get(1); map.put(1, value + 1); }//from ww w . java 2 s. c om if (2 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(2) == null ? 0 : map.get(2); map.put(2, value + 1); } if (3 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(3) == null ? 0 : map.get(3); map.put(3, value + 1); } if (4 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(4) == null ? 0 : map.get(4); map.put(4, value + 1); } if (5 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(5) == null ? 0 : map.get(5); map.put(5, value + 1); } if (6 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(6) == null ? 0 : map.get(6); map.put(6, value + 1); } if (7 == c.get(Calendar.DAY_OF_WEEK)) { Integer value = map.get(7) == null ? 0 : map.get(7); map.put(7, value + 1); } } } return map; } }