Java Month of Year getWorkDayNum(int year, int month, int start, int end)

Here you can find the source of getWorkDayNum(int year, int month, int start, int end)

Description

get Work Day Num

License

Open Source License

Declaration

public static Map<Integer, Integer> getWorkDayNum(int year, int month, int start, int end) 

Method Source Code

//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;
    }
}

Related

  1. getTime(int year, int month, int day)
  2. getTimeByYMD(int year, int month, int day)
  3. getTimestamp(int year, int month, int day, int hour, int minute, int second, int millisecond)
  4. getTodayAdd(int year, int month, int day)
  5. getWeek(int year, int month, int day)
  6. isDefaultHolidays(int year, int month, int day)
  7. isWeekEnd(int year, int month, int day)
  8. Month_Of_Year(String Date, int MonthCase)
  9. monthLength(int month, int year)