Java Day of isHoliday(Date date, String[] excludes, String[] includes)

Here you can find the source of isHoliday(Date date, String[] excludes, String[] includes)

Description

is Holiday

License

Open Source License

Declaration

public static boolean isHoliday(Date date, String[] excludes, String[] includes) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static boolean isHoliday(Date date, String[] excludes, String[] includes) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMdd");
        if (date == null) {
            date = new Date();
        }// w w w  .j ava2  s  . c o  m
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int week = calendar.get(Calendar.DAY_OF_WEEK);
        String today = simpleDateFormat.format(calendar.getTime());
        if (week == 1 || week == 7) {
            if (excludes != null) {
                for (int i = 0, len = excludes.length; i < len; ++i) {
                    if (today.equals(excludes[i])) {
                        return false;
                    }
                }
            }
            return true;
        } else {
            if (includes != null) {
                for (int i = 0, len = includes.length; i < len; ++i) {
                    if (today.equals(includes[i])) {
                        return true;
                    }
                }
            }
            return false;
        }
    }
}

Related

  1. getYesday()
  2. getYYYY_MM_DD(int offsetDays)
  3. isBirthdayPartAvail(String number)
  4. isDiffIsBiggerThanMin(Date lastLogIn, Date now, Long daysL)
  5. isEndOfDay(GregorianCalendar cal1)
  6. isIn(int reserveDayCount, String dateString)
  7. isInAllDayFormat(String date)
  8. isNowDay(String d)
  9. isSomeDay(String date)