Java Day of Work isWorkDay(Date date)

Here you can find the source of isWorkDay(Date date)

Description

is Work Day

License

Open Source License

Declaration

public static final boolean isWorkDay(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static final boolean isWorkDay(Date date) {
        if (date == null) {
            throw new IllegalArgumentException("date is null.");
        }/*  w w  w .j  a v  a 2  s.c om*/
        boolean ret = true;
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) {
            ret = false;
        }
        return ret;
    }

    public static int get(Date date, int type) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(type);
    }
}

Related

  1. addWorkdays(Date date, int workdayOffset)
  2. addWorkingDays(Date start, int workingDays)
  3. getRemainingWorkingMonth(Date taxdate)
  4. getWorkDay(Date d1, Date d2, int[] freeDays)
  5. isWorkDay(Date data)
  6. isWorkday(Date date)
  7. isWorking(final Date date)