Here you can find the source of isWorkingDay(final Calendar calendar, final Long[] holidays)
public static boolean isWorkingDay(final Calendar calendar, final Long[] holidays)
//package com.java2s; //License from project: LGPL import java.util.*; public class Main { /**/* w w w . j a va 2s.com*/ * MONTH=2 * */ public static final int MONTH = Calendar.MONTH; /** * Year=1 * */ public static final int YEAR = Calendar.YEAR; /** * no-working days */ private static final int[] highDays = { Calendar.SUNDAY, Calendar.SATURDAY }; /** * Return true if the day is a working day * * @param date Date * @param holidays Array of holidays * @return Return true if the day is a working day */ public static boolean isWorkingDay(final Date date, final Long[] holidays) { return isWorkingDay(date.getTime(), holidays); } /** * Return true if the day is a working day * * @param time Long - time in milliseconds * @param holidays Array of holidays * @return Return true if the day is a working day */ public static boolean isWorkingDay(final long time, final Long[] holidays) { final Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); return isWorkingDay(calendar, holidays); } public static boolean isWorkingDay(final Calendar calendar, final Long[] holidays) { // check if in holiday if (null != holidays) { final Calendar holiday = Calendar.getInstance(); for (final long d : holidays) { holiday.setTimeInMillis(d); if (holiday.get(Calendar.YEAR) == calendar.get(Calendar.YEAR) && holiday.get(Calendar.MONTH) == calendar.get(Calendar.MONTH) && holiday.get(Calendar.DAY_OF_MONTH) == calendar.get(Calendar.DAY_OF_MONTH)) { return false; } } } // check day of week final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); for (final int i : highDays) { if (i == dayOfWeek) { return false; } } return true; } }