Java Calendar Day toNextWorkDay(Calendar cal)

Here you can find the source of toNextWorkDay(Calendar cal)

Description

to Next Work Day

License

Apache License

Declaration

public static void toNextWorkDay(Calendar cal) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static final String DATE = "yyyy-MM-dd";

    public static void toNextWorkDay(Calendar cal) {
        if (isRestDay(cal)) {
            cal.add(Calendar.DATE, 1);
            toNextWorkDay(cal);/*  w  ww  .  ja  v a  2  s. c o m*/
        }
    }

    public static final boolean isRestDay(Calendar cal) {
        int weekDay = cal.get(Calendar.DAY_OF_WEEK);
        return weekDay == Calendar.SATURDAY || weekDay == Calendar.SUNDAY;
    }

    public static final boolean isRestDay(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        int weekDay = cal.get(Calendar.DAY_OF_WEEK);
        return weekDay == Calendar.SATURDAY || weekDay == Calendar.SUNDAY;
    }
}

Related

  1. setToStartTimeOfTheDay(Calendar c)
  2. startOfDay(Calendar calendar)
  3. toCountWorkDays(GregorianCalendar start, GregorianCalendar end)
  4. todayCalendar()
  5. toEndOfDayCalendar(Date date)
  6. trimToDay(Calendar calendar)
  7. truncateDay(Calendar calendar)