Example usage for java.util Calendar SATURDAY

List of usage examples for java.util Calendar SATURDAY

Introduction

In this page you can find the example usage for java.util Calendar SATURDAY.

Prototype

int SATURDAY

To view the source code for java.util Calendar SATURDAY.

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Saturday.

Usage

From source file:com.aimluck.eip.project.ProjectTaskSelectData.java

/**
 * ??????//from   w  ww.j a  v a  2s . c om
 *
 * @return TRUE:??
 */

public boolean isSaturday(int days) {
    Calendar cal = (Calendar) calFrom.clone();
    cal.add(Calendar.DAY_OF_MONTH, days - 1);
    return Calendar.SATURDAY == cal.get(Calendar.DAY_OF_WEEK);
}

From source file:com.alkacon.opencms.calendar.CmsSerialDateWidget.java

/**
 * Returns the macro resolver with initialized macros to generate the serial date input form.<p>
 * //from www . ja  v  a2s .  c  o m
 * @param cms an initialized instance of a CmsObject
 * @param widgetDialog the dialog where the widget is used on
 * @param param the widget parameter to generate the widget for
 * @return the macro resolver with initialized macros
 */
protected CmsMacroResolver getMacroResolverForForm(CmsObject cms, I_CmsWidgetDialog widgetDialog,
        I_CmsWidgetParameter param) {

    CmsMacroResolver resolver = CmsMacroResolver.newInstance();
    // set cms object and localized messages in resolver
    resolver.setCmsObject(cms);
    CmsMessages messages = new CmsMessages(CmsSerialDateWidget.class.getPackage().getName() + ".messages",
            widgetDialog.getLocale());
    resolver.setMessages(messages);
    // delete empty macros which were not replaced
    resolver.setKeepEmptyMacros(false);

    // create the serial entry date object
    String paramValue = param.getStringValue(cms);
    Map params = CmsStringUtil.splitAsMap(paramValue, String.valueOf(CmsProperty.VALUE_LIST_DELIMITER),
            String.valueOf(CmsProperty.VALUE_MAP_DELIMITER));
    // create the entry date from the field values
    CmsCalendarEntryDateSerial entryDate = CmsCalendarSerialDateFactory.getSerialDate(params,
            widgetDialog.getLocale());
    if (entryDate == null) {
        // no entry date created yet, build an empty default date
        Calendar start = new GregorianCalendar(widgetDialog.getLocale());
        Calendar end = (Calendar) start.clone();
        entryDate = new CmsCalendarEntryDateSerial(start, end);
        entryDate.setSerialEndType(I_CmsCalendarSerialDateOptions.END_TYPE_NEVER);
    }

    // vars for daily options
    String dayDailyInterval = "1";
    boolean dayEveryWorkingDay = false;
    // vars for weekly options
    String weekWeeklyInterval = "1";
    // vars for monthly options
    int monthSelectedIndexWeekDayOfMonth = 0;
    int monthSelectedWeekDay = -1;
    String monthDayOfMonth = "1";
    String monthMonthlyInterval = "1";
    String monthMonthlyIntervalWeekDay = "1";
    boolean monthUseWeekday = false;
    // vars for yearly options
    String yearDayOfMonth = "1";
    boolean yearUseWeekday = false;
    int yearSelectedIndexMonth = 0;
    int yearSelectedIndexWeekDayOfMonth = 0;
    int yearSelectedWeekDayDay = -1;
    int yearSelectedIndexWeekDayMonth = 0;

    if (entryDate.getSerialOptions() != null) {
        // fill the variables depending on the selected serial date type
        String serialTypeMacroPrefix = MACRO_PREFIX_PARAMVALUE + PARAM_SERIALTYPE + ".";
        // set serial type radio selection
        resolver.addMacro(serialTypeMacroPrefix + entryDate.getSerialOptions().getSerialType(), ATTR_CHECKED);
        switch (entryDate.getSerialOptions().getSerialType()) {
        // set values for the selected serial type
        case I_CmsCalendarSerialDateOptions.TYPE_DAILY:
            CmsCalendarSerialDateDailyOptions dailyOptions = (CmsCalendarSerialDateDailyOptions) entryDate
                    .getSerialOptions();
            dayEveryWorkingDay = dailyOptions.isEveryWorkingDay();
            dayDailyInterval = String.valueOf(dailyOptions.getDailyInterval());
            break;
        case I_CmsCalendarSerialDateOptions.TYPE_WEEKLY:
            CmsCalendarSerialDateWeeklyOptions weeklyOptions = (CmsCalendarSerialDateWeeklyOptions) entryDate
                    .getSerialOptions();
            weekWeeklyInterval = String.valueOf(weeklyOptions.getWeeklyInterval());
            // check the chosen week day checkboxes
            serialTypeMacroPrefix = MACRO_PREFIX_PARAMVALUE + PARAM_WEEK_WEEKDAY + ".";
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.MONDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.MONDAY, ATTR_CHECKED);
            }
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.TUESDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.TUESDAY, ATTR_CHECKED);
            }
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.WEDNESDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.WEDNESDAY, ATTR_CHECKED);
            }
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.THURSDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.THURSDAY, ATTR_CHECKED);
            }
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.FRIDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.FRIDAY, ATTR_CHECKED);
            }
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.SATURDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.SATURDAY, ATTR_CHECKED);
            }
            if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.SUNDAY))) {
                resolver.addMacro(serialTypeMacroPrefix + Calendar.SUNDAY, ATTR_CHECKED);
            }
            break;
        case I_CmsCalendarSerialDateOptions.TYPE_MONTHLY:
            CmsCalendarSerialDateMonthlyOptions monthlyOptions = (CmsCalendarSerialDateMonthlyOptions) entryDate
                    .getSerialOptions();
            monthUseWeekday = monthlyOptions.isUseWeekDay();
            if (!monthlyOptions.isUseWeekDay()) {
                monthDayOfMonth = String.valueOf(monthlyOptions.getDayOfMonth());
                monthMonthlyInterval = String.valueOf(monthlyOptions.getMonthlyInterval());
            } else {
                // set selected index of select boxes
                monthSelectedIndexWeekDayOfMonth = monthlyOptions.getDayOfMonth() - 1;
                monthSelectedWeekDay = monthlyOptions.getWeekDay();
                monthMonthlyIntervalWeekDay = String.valueOf(monthlyOptions.getMonthlyInterval());
            }
            break;
        case I_CmsCalendarSerialDateOptions.TYPE_YEARLY:
            CmsCalendarSerialDateYearlyOptions yearlyOptions = (CmsCalendarSerialDateYearlyOptions) entryDate
                    .getSerialOptions();
            yearUseWeekday = yearlyOptions.isUseWeekDay();
            if (!yearlyOptions.isUseWeekDay()) {
                yearDayOfMonth = String.valueOf(yearlyOptions.getDayOfMonth());
                yearSelectedIndexMonth = yearlyOptions.getMonth();
            } else {
                yearSelectedIndexWeekDayOfMonth = yearlyOptions.getDayOfMonth() - 1;
                yearSelectedWeekDayDay = yearlyOptions.getWeekDay();
                yearSelectedIndexWeekDayMonth = yearlyOptions.getMonth();
            }
            break;
        default:
            // nothing do do here, should never happen
        }
    } else {
        // no serial entry created yet, add some defaults
        resolver.addMacro(
                MACRO_PREFIX_PARAMVALUE + PARAM_SERIALTYPE + "." + I_CmsCalendarSerialDateOptions.TYPE_DAILY,
                ATTR_CHECKED);
        resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_WEEK_WEEKDAY + "." + Calendar.MONDAY, ATTR_CHECKED);

    }
    // set time settings
    String startTime = getCalendarLocalizedTime(widgetDialog.getLocale(), widgetDialog.getMessages(),
            entryDate.getStartDate().getTimeInMillis(), false, true);
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_STARTTIME, startTime);

    String endTime = "";
    if (!entryDate.getStartDate().equals(entryDate.getEndDate())) {
        // end time is different from start time, get localized value
        endTime = getCalendarLocalizedTime(widgetDialog.getLocale(), widgetDialog.getMessages(),
                entryDate.getEndDate().getTimeInMillis(), false, true);
    }
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_ENDTIME, endTime);

    resolver.addMacro("select.durationdays",
            buildSelectDurationDays(PARAM_DURATIONDAYS, messages, entryDate.getDuration()));

    // set found values to serial option tabs
    // daily options
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_DAY_DAILYINTERVAL, dayDailyInterval);
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_DAY_EVERYWORKINGDAY + "." + dayEveryWorkingDay,
            ATTR_CHECKED);

    // weekly options
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_WEEK_WEEKLYINTERVAL, weekWeeklyInterval);

    // monthly options
    // mark the correct radio
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_SERIALMONTHDAY + "." + monthUseWeekday,
            ATTR_CHECKED);
    // set the macros for the day of month options
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_DAYOFMONTH, monthDayOfMonth);
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_MONTHLYINTERVAL, monthMonthlyInterval);
    // set the macros for the week day of month options
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_MONTHLYINTERVALWEEKDAY,
            monthMonthlyIntervalWeekDay);
    // build the select boxes
    resolver.addMacro("select.monthnumberofweekday",
            buildSelectNumberOfWeekDayOfMonth(
                    PARAM_MONTH_NUMBEROFWEEKDAYOFMONTH, "onfocus=\"document.getElementById('"
                            + PARAM_MONTH_SERIALMONTHDAY + ".true').checked = true;\"",
                    messages, monthSelectedIndexWeekDayOfMonth));
    resolver.addMacro("select.monthweekday",
            buildSelectWeekDay(PARAM_MONTH_WEEKDAY, "onfocus=\"document.getElementById('"
                    + PARAM_MONTH_SERIALMONTHDAY + ".true').checked = true;\"", messages,
                    monthSelectedWeekDay));

    // yearly options
    // mark the correct radio
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_YEAR_SERIALYEARDAY + "." + yearUseWeekday, ATTR_CHECKED);
    // set the macros for the day of month options
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_YEAR_DAYOFMONTH, yearDayOfMonth);
    resolver.addMacro("select.yearmonth", buildSelectMonth(PARAM_YEAR_MONTH,
            "onfocus=\"document.getElementById('" + PARAM_YEAR_SERIALYEARDAY + ".false').checked = true;\"",
            messages, yearSelectedIndexMonth));
    // set the macros for the week day of month options
    resolver.addMacro("select.yearnumberofweekday",
            buildSelectNumberOfWeekDayOfMonth(PARAM_YEAR_WEEKDAYOFMONTH, "onfocus=\"document.getElementById('"
                    + PARAM_YEAR_SERIALYEARDAY + ".true').checked = true;\"", messages,
                    yearSelectedIndexWeekDayOfMonth));
    resolver.addMacro("select.yearweekday",
            buildSelectWeekDay(PARAM_YEAR_WEEKDAY, "onfocus=\"document.getElementById('"
                    + PARAM_YEAR_SERIALYEARDAY + ".true').checked = true;\"", messages,
                    yearSelectedWeekDayDay));
    resolver.addMacro("select.yearmonthweekday",
            buildSelectMonth(PARAM_YEAR_WEEKDAYMONTH, "onfocus=\"document.getElementById('"
                    + PARAM_YEAR_SERIALYEARDAY + ".true').checked = true;\"", messages,
                    yearSelectedIndexWeekDayMonth));

    // set serial duration values

    // set start date
    resolver.addMacro("calendar.startdate",
            buildDateInput("startdate", widgetDialog, entryDate.getStartDate()));
    Calendar serialEndDate = entryDate.getSerialEndDate();
    if (serialEndDate == null) {
        serialEndDate = entryDate.getStartDate();
    }
    resolver.addMacro("calendar.serialenddate", buildDateInput("serialenddate", widgetDialog, serialEndDate));

    // set occurences
    int occurences = 10;
    if (entryDate.getSerialEndType() == I_CmsCalendarSerialDateOptions.END_TYPE_TIMES) {
        occurences = entryDate.getOccurences();
    }
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_OCCURENCES, String.valueOf(occurences));

    // set the end type radio buttons
    resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_ENDTYPE + "." + entryDate.getSerialEndType(),
            ATTR_CHECKED);

    return resolver;
}

From source file:org.olat.commons.calendar.ui.components.WeeklyCalendarComponentRenderer.java

private void renderWeekHeader(final int year, final int weekOfYear, final boolean enableAddEvent,
        final StringOutput sb, final URLBuilder ubu, final Locale locale) {
    final Calendar cal = CalendarUtils.getStartOfWeekCalendar(year, weekOfYear, locale);
    final Calendar calNow = CalendarUtils.createCalendarInstance(locale);
    cal.set(Calendar.HOUR_OF_DAY, calNow.get(Calendar.HOUR_OF_DAY));
    cal.set(Calendar.MINUTE, calNow.get(Calendar.MINUTE));
    final SimpleDateFormat dayMonth = new SimpleDateFormat("E dd.MM", locale);

    // render header
    sb.append("\n<div id=\"o_cal_wv_header\">");
    sb.append("<div class=\"o_cal_wv_time o_cal_wv_row0\">");
    sb.append("<div class=\"o_cal_wv_legend_hours\"><div></div></div></div>");
    int dayToday = -1;
    if ((calNow.get(Calendar.WEEK_OF_YEAR) == weekOfYear) && (calNow.get(Calendar.YEAR) == year)) {
        // if we are within current week, adjust dayToday
        dayToday = calNow.get(Calendar.DAY_OF_WEEK);
    }//from   w w  w.j av  a2  s. c  o  m
    for (int i = 1; i <= days; i++) {
        final int dayOfWeekIter = cal.get(Calendar.DAY_OF_WEEK);
        sb.append("\n<div class=\"o_cal_wv_day ");
        sb.append("o_cal_wv_row");
        sb.append(i);
        sb.append(" ");
        if (i == 7) {
            // terminate last day
            sb.append("o_cal_wv_lastday ");
        }
        if (dayOfWeekIter == dayToday) {
            // current day
            sb.append("o_cal_wv_today ");
        } else if (dayOfWeekIter == Calendar.SATURDAY || dayOfWeekIter == Calendar.SUNDAY) {
            // holiday
            sb.append("o_cal_wv_holiday ");
        }
        sb.append("\">");
        sb.append("<div class=\"o_cal_wv_legend_day\"><div>");
        if (enableAddEvent) {
            sb.append("<a href=\"");
            ubu.buildURI(sb, new String[] { WeeklyCalendarComponent.ID_CMD, WeeklyCalendarComponent.ID_PARAM },
                    new String[] { WeeklyCalendarComponent.CMD_ADD_ALLDAY,
                            dmyDateFormat.format(cal.getTime()) },
                    isIframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
            sb.append("\" ");
            if (isIframePostEnabled) {
                ubu.appendTarget(sb);
            }
            sb.append(" onclick=\"return o2cl();\">");
            sb.append(dayMonth.format(cal.getTime()));
            sb.append("</a>");
        } else {
            sb.append(dayMonth.format(cal.getTime()));
        }
        sb.append("</div></div></div>");
        // add one day to calendar
        cal.add(Calendar.DAY_OF_YEAR, 1);
    }
    sb.append("</div>");
}

From source file:com.autentia.intra.bean.activity.ActivityBean.java

/**
 * @return// www. ja  v a 2s .  c  om
 */
public float getMonthTotalHours() {

    ArrayList<Integer> diasContemplados = new ArrayList<Integer>();

    cal.setTime(selectedDate);

    float hoursPerDay = ((SettingBean) FacesUtils.getBean("settingBean")).getMySettings().getWorkingHours();

    int weekendsInMonth = 0;

    int daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);

    for (int i = 1; i <= daysInMonth; i++) {
        cal.set(Calendar.DAY_OF_MONTH, i);
        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
                || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            weekendsInMonth++;
            diasContemplados.add(i);
        }
    }

    // Restamos das de vacaciones aceptadas y dias de fiesta

    Calendar calMin = Calendar.getInstance();
    Calendar calMax = Calendar.getInstance();
    Calendar calAux = Calendar.getInstance();

    calMin.setTime(selectedDate);
    calMin.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DAY_OF_MONTH));
    calMin.set(Calendar.HOUR_OF_DAY, cal.getMinimum(Calendar.HOUR_OF_DAY));
    calMin.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
    calMin.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
    calMin.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));

    calMax.setTime(selectedDate);
    calMax.set(Calendar.DAY_OF_MONTH, cal.getMaximum(Calendar.DAY_OF_MONTH));
    calMax.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
    calMax.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
    calMax.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
    calMax.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));

    HolidaySearch monthSearch = new HolidaySearch();

    monthSearch.setStartDate(calMin.getTime());
    monthSearch.setEndDate(calMax.getTime());
    List<Holiday> listaHolidays = holidayManager.getAllEntities(monthSearch, null);

    int holidays = 0;
    for (Holiday holiday : listaHolidays) {
        calAux.setTime(holiday.getDate());
        int day = calAux.get(Calendar.DAY_OF_MONTH);
        if (!diasContemplados.contains(day)) {
            holidays++;
            diasContemplados.add(day);
        }
    }

    int requestedHolidays = 0;
    RequestHolidayManager rhManager = RequestHolidayManager.getDefault();
    RequestHolidaySearch rhSearch = new RequestHolidaySearch();
    rhSearch.setUserRequest(authManager.getCurrentPrincipal().getUser());
    rhSearch.setState(HolidayState.ACCEPT);
    rhSearch.setStartBeginDate(calMin.getTime());
    rhSearch.setEndBeginDate(calMax.getTime());
    rhSearch.setStartFinalDate(calMin.getTime());
    rhSearch.setEndFinalDate(calMax.getTime());

    List<RequestHoliday> listH = rhManager.getAllEntities(rhSearch, null);

    for (RequestHoliday rH : listH) {
        Calendar cActual = Calendar.getInstance();
        cActual.setTime(rH.getBeginDate());
        while (!cActual.getTime().after(rH.getFinalDate())) {
            int day = cActual.get(Calendar.DAY_OF_MONTH);
            if (!diasContemplados.contains(day)) {
                requestedHolidays++;
                diasContemplados.add(day);
            }
            cActual.add(Calendar.DAY_OF_MONTH, 1);
        }

    }

    return (daysInMonth - weekendsInMonth - holidays - requestedHolidays) * hoursPerDay;
}

From source file:dbtimetable.DBTimetableMIDletClass.java

private boolean is_saturday(Calendar the_date) {
    if (the_date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
        return true;
    } else {/* w ww  .  j  av a  2 s  .c o m*/
        return false;
    }
}

From source file:org.eevolution.form.VCRP.java

public boolean checkResourceTypeAvailability(Timestamp dateTime, MResourceType t) {

    if (!t.isDateSlot()) {

        return true;
    }/*from w w w  .  j a va 2s .  c om*/

    GregorianCalendar gc = new GregorianCalendar();
    gc.setTimeInMillis(dateTime.getTime());

    boolean retValue = false;
    switch (gc.get(Calendar.DAY_OF_WEEK)) {

    case Calendar.SUNDAY:
        retValue = t.isOnSunday();
        break;

    case Calendar.MONDAY:
        retValue = t.isOnMonday();
        break;

    case Calendar.TUESDAY:
        retValue = t.isOnTuesday();
        break;

    case Calendar.WEDNESDAY:
        retValue = t.isOnWednesday();
        break;

    case Calendar.THURSDAY:
        retValue = t.isOnThursday();
        break;

    case Calendar.FRIDAY:
        retValue = t.isOnFriday();
        break;

    case Calendar.SATURDAY:
        retValue = t.isOnSaturday();
        break;
    }

    return retValue;
}

From source file:org.olat.commons.calendar.ui.components.WeeklyCalendarComponentRenderer.java

private void renderWeekGrid(final int year, final int weekOfYear, final boolean enableAddEvent,
        final StringOutput sb, final URLBuilder ubu, final Locale locale) {
    final Calendar cal = CalendarUtils.getStartOfWeekCalendar(year, weekOfYear, locale);
    int dayToday = -1;
    final Calendar calNow = CalendarUtils.createCalendarInstance(locale);
    if ((calNow.get(Calendar.WEEK_OF_YEAR) == weekOfYear) && (calNow.get(Calendar.YEAR) == year)) {
        // if we are within current week, adjust dayToday
        dayToday = calNow.get(Calendar.DAY_OF_WEEK);
    }//from  w  ww .j av a  2  s. co m

    // render day grid
    sb.append("\n<div class=\"o_cal_wv_time o_cal_wv_row0\">");
    for (int i = 0; i < 23; i++) {
        sb.append("<div class=\"o_cal_wv_legend_hour\"><div>");
        sb.append(i);
        sb.append(":00</div></div>");
    }
    sb.append("<div class=\"o_cal_wv_legend_hour o_cal_wv_lasthour\"><div>23:00</div></div></div>");

    // render daily grid
    // reposition calendar to start of week
    for (int i = 1; i <= 7; i++) {
        final int dayOfWeekIter = cal.get(Calendar.DAY_OF_WEEK);
        sb.append("\n<div class=\"o_cal_wv_day o_cal_wv_row");
        sb.append(i);
        if (dayOfWeekIter == dayToday) {
            // current day
            sb.append(" o_cal_wv_today");
        } else if (dayOfWeekIter == Calendar.SATURDAY || dayOfWeekIter == Calendar.SUNDAY) {
            // holiday
            sb.append(" o_cal_wv_holiday");
        }
        sb.append("\">");

        for (int j = 0; j < 23; j++) {
            // set calendar add link to corresponding hour
            cal.set(Calendar.HOUR_OF_DAY, j);

            // build the add event uri
            final StringOutput uri = new StringOutput();
            ubu.buildJavaScriptBgCommand(uri,
                    new String[] { WeeklyCalendarComponent.ID_CMD, WeeklyCalendarComponent.ID_PARAM },
                    new String[] { WeeklyCalendarComponent.CMD_ADD, dmyDateFormat.format(cal.getTime()) },
                    isIframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL, true);

            sb.append("<div class=\"o_cal_wv_hour\"");
            if (enableAddEvent) {
                sb.append(" onclick=\"");
                sb.append(uri);
            }
            sb.append("\"></div>");
            sb.append("<div class=\"o_cal_wv_half_hour\"");
            if (enableAddEvent) {
                sb.append(" onclick=\"");
                sb.append(uri);
            }
            sb.append("\"></div>");
        }
        // set calendar add link to last hour (23)
        cal.set(Calendar.HOUR_OF_DAY, 23);
        final StringOutput uri = new StringOutput();
        ubu.buildJavaScriptBgCommand(uri,
                new String[] { WeeklyCalendarComponent.ID_CMD, WeeklyCalendarComponent.ID_PARAM },
                new String[] { WeeklyCalendarComponent.CMD_ADD, dmyDateFormat.format(cal.getTime()) },
                isIframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL, true);

        sb.append("<div class=\"o_cal_wv_hour\"");
        if (enableAddEvent) {
            sb.append(" onclick=\"");
            sb.append(uri);
        }
        sb.append("\"></div>");
        sb.append("<div class=\"o_cal_wv_half_hour o_cal_wv_lasthour\"");
        if (enableAddEvent) {
            sb.append(" onclick=\"");
            sb.append(uri);
        }
        sb.append("\"></div></div>");
        cal.add(Calendar.DAY_OF_YEAR, 1);
    }

}

From source file:com.adito.boot.Util.java

/**
 * Get a day of week constant suitable for use with {@link Calendar}
 * given an english day day. This may be any case and only the first
 * 3 characters are tested for (i.e. sun, mon, tue, etc ..)
 * // ww  w . j a v a  2s.  c o  m
 * @param text
 * @return day of week
 */
public static int getDayOfWeekForText(String text) {
    text = text.toLowerCase();
    if (text.startsWith("sun")) {
        return Calendar.SUNDAY;
    } else if (text.startsWith("mon")) {
        return Calendar.MONDAY;
    } else if (text.startsWith("tue")) {
        return Calendar.TUESDAY;
    } else if (text.startsWith("wed")) {
        return Calendar.WEDNESDAY;
    } else if (text.startsWith("thu")) {
        return Calendar.THURSDAY;
    } else if (text.startsWith("fri")) {
        return Calendar.FRIDAY;
    } else if (text.startsWith("sat")) {
        return Calendar.SATURDAY;
    }
    return 0;
}

From source file:com.aimluck.eip.schedule.util.ScheduleUtils.java

/**
 * ?????????????/*from w  ww.jav a 2 s  .  co m*/
 *
 * @param date
 * @param ptn
 * @param startDate
 * @param limitDate
 * @return
 */
public static boolean isView(ALDateTimeField date, String ptn, Date startDate, Date limitDate) {
    int count = 0;
    boolean result = false;
    Calendar cal = Calendar.getInstance();
    cal.setTime(date.getValue());
    // 
    if (ptn.charAt(0) == 'D') {
        result = true;
        count = 1;
        // , 
    } else if (ptn.charAt(0) == 'W') {

        int dow = cal.get(Calendar.DAY_OF_WEEK);
        // ??
        int dowim = cal.get(Calendar.DAY_OF_WEEK_IN_MONTH);
        if (ptn.charAt(8) == 'N' || ptn.charAt(8) == 'L' || dowim == Character.getNumericValue(ptn.charAt(8))) {
            switch (dow) {
            // 
            case Calendar.SUNDAY:
                result = ptn.charAt(1) != '0';
                break;
            // 
            case Calendar.MONDAY:
                result = ptn.charAt(2) != '0';
                break;
            // ?
            case Calendar.TUESDAY:
                result = ptn.charAt(3) != '0';
                break;
            // 
            case Calendar.WEDNESDAY:
                result = ptn.charAt(4) != '0';
                break;
            // 
            case Calendar.THURSDAY:
                result = ptn.charAt(5) != '0';
                break;
            // 
            case Calendar.FRIDAY:
                result = ptn.charAt(6) != '0';
                break;
            // 
            case Calendar.SATURDAY:
                result = ptn.charAt(7) != '0';
                break;
            default:
                result = false;
                break;
            }
            if (ptn.length() == 9) {
                count = 8;
            } else {
                count = 9;
            }
        }
        // 
    } else if (ptn.charAt(0) == 'M') {
        int mday;
        if (ptn.substring(1, 3).equals("XX")) {
            mday = cal.getActualMaximum(Calendar.DATE);
        } else {
            mday = Integer.parseInt(ptn.substring(1, 3));
        }
        result = Integer.parseInt(date.getDay()) == mday;
        count = 3;
    } else if (ptn.charAt(0) == 'Y') {
        int ymonth = Integer.parseInt(ptn.substring(1, 3));
        int yday = Integer.parseInt(ptn.substring(3, 5));
        int month = Integer.parseInt(date.getMonth());
        int day = Integer.parseInt(date.getDay());
        if (ymonth == month && yday == day) {
            result = true;
            count = 5;
        } else {
            result = false;
        }
    } else {
        return true;
    }

    if (result) {
        if (ptn.charAt(count) == 'L') {
            // ????
            if (equalsToDate(startDate, date.getValue(), false)
                    || equalsToDate(limitDate, date.getValue(), false)) {
                // ???
                result = true;
            } else {
                // ????????????
                result = result && startDate.before(cal.getTime()) && limitDate.after(cal.getTime());
            }
        }
    }

    return result;
}

From source file:org.pentaho.di.core.row.ValueDataUtil.java

public static Object DateWorkingDiff(ValueMetaInterface metaA, Object dataA, ValueMetaInterface metaB,
        Object dataB) throws KettleValueException {
    if (dataA != null && dataB != null) {
        Date fromDate = metaB.getDate(dataB);
        Date toDate = metaA.getDate(dataA);
        boolean singminus = false;

        if (fromDate.after(toDate)) {
            singminus = true;/* ww  w . ja  va 2  s  .  c om*/
            Date temp = fromDate;
            fromDate = toDate;
            toDate = temp;
        }
        Calendar calFrom = Calendar.getInstance();
        calFrom.setTime(fromDate);
        Calendar calTo = Calendar.getInstance();
        calTo.setTime(toDate);
        int iNoOfWorkingDays = 0;
        do {
            if (calFrom.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY
                    && calFrom.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                iNoOfWorkingDays += 1;
            }
            calFrom.add(Calendar.DATE, 1);
        } while (calFrom.getTimeInMillis() < calTo.getTimeInMillis());
        return new Long(singminus ? -iNoOfWorkingDays : iNoOfWorkingDays);
    } else {
        return null;
    }
}