Here you can find the source of getNumberOfDayOfWeekInDays(long days, int firstDayOfWeek, int... dayOfWeek)
public static long getNumberOfDayOfWeekInDays(long days, int firstDayOfWeek, int... dayOfWeek)
//package com.java2s; public class Main { public static long getNumberOfDayOfWeekInDays(long days, int firstDayOfWeek, int... dayOfWeek) { if (dayOfWeek == null) return 0; if (dayOfWeek.length == 7) return days; long count = 0; long weeks = days / 7; long offset = days % 7; if (offset > 0) { int[] weekOfDays = new int[(int) offset]; for (int i = 0; i < offset; i++) { weekOfDays[i] = (firstDayOfWeek - 1 + i) % 7 + 1; }/*from ww w . jav a2s . c o m*/ next: for (int j = 0; j < dayOfWeek.length; j++) { for (int i = 0; i < weekOfDays.length; i++) { if (dayOfWeek[j] == weekOfDays[i]) { count++; continue next; } } } } count += weeks * dayOfWeek.length; return count; } }