Java Day of Week getFirstWeekdayBetween(Date fromDate, Date toDate, int dayOfWeek)

Here you can find the source of getFirstWeekdayBetween(Date fromDate, Date toDate, int dayOfWeek)

Description

get First Weekday Between

License

Open Source License

Declaration

public static Date getFirstWeekdayBetween(Date fromDate, Date toDate, int dayOfWeek) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getFirstWeekdayBetween(Date fromDate, Date toDate, int dayOfWeek) {
        Calendar aDay = Calendar.getInstance();
        aDay.setTime(fromDate);/* www  . j a v  a 2s .c  om*/
        while (aDay.getTime().before(toDate)) {
            if (aDay.get(Calendar.DAY_OF_WEEK) == dayOfWeek) {
                return aDay.getTime();
            }
            aDay.add(Calendar.DATE, 1);
        }
        return null;
    }
}

Related

  1. getFirstDayOfWeek(int year, int week)
  2. getFirstDayOfWeek(int year, int week)
  3. getFirstDayOfWeek(int year, int week)
  4. getFirstDayWeekly(final int year)
  5. getFirstMonthWeek(Date month)
  6. getFirstWeekofMonth(Date date1)
  7. getIntervalIncludeWeekend(Date date)
  8. getISO8601WeekOfYear(Date date)
  9. getIsoDayOfWeek(Date date)