Here you can find the source of isTodayOff(String days, Calendar calendar)
Parameter | Description |
---|---|
days | - Off days for the department. |
calendar | - The calendar instance of the day which is used to check for off days. |
public static Boolean isTodayOff(String days, Calendar calendar)
//package com.java2s; import java.util.Calendar; public class Main { /**/*from w ww . j av a 2 s . c o m*/ * This method is used to check whether the day passed as parameter is an * off day. * * @param days - * Off days for the department. * @param calendar - * The calendar instance of the day which is used to check for * off days. * @return isOff - true or false depending on whether it is off day or not. */ public static Boolean isTodayOff(String days, Calendar calendar) { Boolean isOff = false; Integer today = 0; today = calendar.get(Calendar.DAY_OF_WEEK); // This is default value switch (today) { case Calendar.SUNDAY: if (days.contains("SU")) { isOff = true; } break; case Calendar.MONDAY: if (days.contains("MO")) { isOff = true; } break; case Calendar.TUESDAY: if (days.contains("TU")) { isOff = true; } break; case Calendar.WEDNESDAY: if (days.contains("WE")) { isOff = true; } break; case Calendar.THURSDAY: if (days.contains("TH")) { isOff = true; } break; case Calendar.FRIDAY: if (days.contains("FR")) { isOff = true; } break; case Calendar.SATURDAY: if (days.contains("SA")) { isOff = true; } break; default: // throw Business exceptions. } return isOff; } }