Java Utililty Methods Day of Work

List of utility methods to do Day of Work

Description

The list of methods to do Day of Work are organized into topic(s).

Method

DateaddWorkdays(Date date, int workdayOffset)
Die Anzahl Arbeitstage (d.h.
final Calendar cal = getCalendarInstance();
cal.setTime(date);
ensureWorkday(cal);
for (int countdown = workdayOffset; countdown > 0; countdown--) {
    cal.add(Calendar.DAY_OF_YEAR, 1);
    ensureWorkday(cal);
final Date result = cal.getTime();
...
DateaddWorkingDays(Date start, int workingDays)
Takes a start date and adds the specified number of working days to it.
if (workingDays < 0) {
    throw new IllegalArgumentException("Subtracting of working days is currently not supported.");
} else if (workingDays == 0) {
    return start;
} else {
    final GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(start);
    final int startDay = cal.get(Calendar.DAY_OF_WEEK);
...
intgetRemainingWorkingMonth(Date taxdate)
get Remaining Working Month
Calendar calendar = Calendar.getInstance();
calendar.setTime(taxdate);
int month = calendar.get(Calendar.MONTH) + 1;
return 12 - month;
intgetWorkDay(Date d1, Date d2, int[] freeDays)
get Work Day
int dNum = 0;
dNum = (int) ((d2.getTime() - d1.getTime()) / 1000 / 60 / 60 / 24) + 1;
return dNum - getFreeDay(d1, dNum, freeDays);
booleanisWorkDay(Date data)
is Work Day
int theDay = getCalendar(data).get(Calendar.DAY_OF_WEEK);
return theDay != Calendar.SUNDAY && theDay != Calendar.SATURDAY;
booleanisWorkDay(Date date)
is Work Day
if (date == null) {
    throw new IllegalArgumentException("date is null.");
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) {
...
booleanisWorkday(Date date)
is Workday
Calendar cal = Calendar.getInstance();
if (date != null) {
    cal.setTime(date);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
return !(dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY);
booleanisWorking(final Date date)
is Working
final int hourOfDay = getHourOfDay(date);
if (hourOfDay > 8 && hourOfDay < 19) {
    return true;
return false;