Android Week Day Get getNumberOfDayOfWeekInDays(long days, int firstDayOfWeek, int... dayOfWeek)

Here you can find the source of getNumberOfDayOfWeekInDays(long days, int firstDayOfWeek, int... dayOfWeek)

Description

get Number Of Day Of Week In Days

Declaration

public static long getNumberOfDayOfWeekInDays(long days,
            int firstDayOfWeek, int... dayOfWeek) 

Method Source Code

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

Related

  1. monthDaysToIntWeekDays(String dayOfMonth)
  2. convertDayOfWeekFromTimeToCalendar(int timeDayOfWeek)
  3. getDayOfWeek(int index)
  4. getShortDaysOfWeekNames()