EgovDateUtil { public static int getDayOfWeekCount(String from, String to, String yoil) throws ParseException { int first = 0; int count = 0; String[] sYoil = { "일", "월", "화", "수", "목", "금", "토" }; int betweenDays = getDayCount(from, to); Calendar cd = new GregorianCalendar(Integer.parseInt(from.substring(0, 4)), Integer.parseInt(from.substring(4, 6)) - 1, Integer.parseInt(from.substring(6, 8))); int dayOfWeek = cd.get(Calendar.DAY_OF_WEEK); if (yoil.length() == 3) { yoil = yoil.substring(0, 1); } while (!sYoil[(dayOfWeek - 1) % 7].equals(yoil)) { dayOfWeek += 1; first++; } if ((betweenDays - first) < 0) { return 0; } else { count++; } count += (betweenDays - first) / 7; return count; } protected  EgovDateUtil(); static String getCalcDateAsString(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static String getCalcYearAsString(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static String getCalcMonthAsString(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static String getCalcDayAsString(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static int getCalcYearAsInt(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static int getCalcMonthAsInt(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static int getCalcDayAsInt(String sYearPara, String sMonthPara, String sDayPara, int iTerm, String sGuBun); static int getCurrentYearAsInt(); static int getCurrentMonthAsInt(); static int getCurrentDayAsInt(); static int getCurrentHourAsInt(); static int getCurrentMinuteAsInt(); static int getCurrentMilliSecondAsInt(); static String getCurrentYearAsString(); static String getCurrentMonthAsString(); static String getCurrentDayAsString(); static String getCurrentHourAsString(); static String getCurrentMinuteAsString(); static String getCurrentSecondAsString(); static String getCurrentMilliSecondAsString(); static String getCurrentDateAsString(); static String getCurrentTimeAsString(); static String getCurrentDateTimeAsString(); static String getDayOfWeekAsString(String sYear, String sMonth, String sDay); static int getFullAge(String socialNo, String keyDate); static int getCurrentFullAge(String socialNo); static int getDayCountForMonth(int year, int month); static int getDayCount(String from, String to); static Date dateFormatCheck(String source); static Date dateFormatCheck(String source, String format); static int getDayCountWithFormatter(String from, String to, String format); static long getTimeCount(String from, String to); static long getTimeCount(String from, String to, String format); static int getDayOfWeekCount(String from, String to, String yoil); static String toString(Date date, String format, Locale locale);  }
@Test public void testDayOfWeekCount() throws Exception { assertEquals(5, EgovDateUtil.getDayOfWeekCount("20090301", "20090331", "월요일")); assertEquals(5, EgovDateUtil.getDayOfWeekCount("20090301", "20090331", "일")); assertEquals(4, EgovDateUtil.getDayOfWeekCount("20090301", "20090331", "토")); assertEquals(22, EgovDateUtil.getDayOfWeekCount("20090101", "20090531", "일")); assertEquals(52, EgovDateUtil.getDayOfWeekCount("20090101", "20091231", "일")); assertEquals(52, EgovDateUtil.getDayOfWeekCount("20090101", "20091231", "금")); assertEquals(52, EgovDateUtil.getDayOfWeekCount("20090101", "20091231", "토")); }