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.idega.block.cal.renderer.AbstractCompactScheduleRenderer.java

/**
 * <p>// w  w w  . java 2s  . c o  m
 * Draw one day in the schedule
 * </p>
 * 
 * @param context
 *            the FacesContext
 * @param writer
 *            the ResponseWriter
 * @param schedule
 *            the schedule
 * @param day
 *            the day that should be drawn
 * @param cellWidth
 *            the width of the cell
 * @param dayOfWeek
 *            the day of the week
 * @param dayOfMonth
 *            the day of the month
 * @param isWeekend
 *            is it a weekend day?
 * @param isCurrentMonth
 *            is the day in the currently selected month?
 * @param rowspan
 *            the rowspan for the table cell
 * 
 * @throws IOException
 *             when the cell could not be drawn
 */
protected void writeDayCell(FacesContext context, ResponseWriter writer, HtmlSchedule schedule, ScheduleDay day,
        float cellWidth, int dayOfWeek, int dayOfMonth, boolean isWeekend, boolean isCurrentMonth, int rowspan)
        throws IOException {

    final String clientId = schedule.getClientId(context);
    final Map<String, Object> attributes = schedule.getAttributes();
    final FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context);
    final String formId = parentFormInfo == null ? null : parentFormInfo.getFormName();

    TimeZone tz = TimeZone.getDefault();
    final String dayHeaderId = clientId + "_header_" + ScheduleUtil.getDateId(day.getDate(), tz);
    final String dayBodyId = clientId + "_body_" + ScheduleUtil.getDateId(day.getDate(), tz);

    boolean isMonthMode = false;
    boolean isWeekMode = false;

    boolean isFirstInARow = false;

    if (cellWidth == 100f / 6) {
        isMonthMode = true;
    } else if (cellWidth == 50f) {
        isWeekMode = true;
    }

    if ((dayOfWeek != Calendar.SUNDAY) && isMonthMode) {
        writer.startElement(HTML.DIV_ELEM, schedule);
    }
    if (isWeekMode && (dayOfWeek != Calendar.SUNDAY)) {
        writer.startElement(HTML.DIV_ELEM, schedule);
    }
    String dayClass = null;
    if (isWeekMode) {
        dayClass = "";
    } else {
        dayClass = getStyleClass(schedule, isCurrentMonth ? "day" : "inactive-day") + " "
                + getStyleClass(schedule, isWeekend ? "weekend" : "workday");
    }

    // add class for sunday

    if ((dayOfWeek == Calendar.MONDAY) || (dayOfWeek == Calendar.WEDNESDAY) || (dayOfWeek == Calendar.FRIDAY)// ||
    ) {
        isFirstInARow = true;
    }

    if (dayOfWeek == Calendar.SUNDAY) {
        dayClass += " sunday";
    }

    if (dayOfWeek == Calendar.SATURDAY) {
        dayClass += " saturday";
    }

    if ((dayOfWeek != Calendar.SUNDAY) && isMonthMode) {
        writer.writeAttribute(HTML.CLASS_ATTR, "workdaytest", null);

    }
    if ((dayOfWeek != Calendar.SUNDAY) && isWeekMode) {
        if (isFirstInARow) {
            writer.writeAttribute(HTML.CLASS_ATTR, "weekTest firstInAWeekRow", null);
        } else {
            writer.writeAttribute(HTML.CLASS_ATTR, "weekTest secondInAWeekRow", null);
        }
    }

    // determine the height of the day in pixels
    StringBuffer styleBuffer = new StringBuffer();

    int rowHeight = getRowHeight(attributes);
    String myRowHeight = "height: ";
    String myContentHeight = "height: ";

    if (rowHeight > 0) {
        if (isWeekend) {
            myRowHeight += (rowHeight / 2) + "px;";
            myContentHeight += ((rowHeight / 2) - 19) + "px;";
        } else {
            myRowHeight += (rowHeight + 1) + "px;"; //need to add 1 to get the weekends right
            myContentHeight += ((rowHeight + 1) - 18) + "px;"; //18 instead of 19, to get the weekends right
        }
    } else {
        myRowHeight += "100%;";
        myContentHeight += "100%;";
    }

    styleBuffer.append(myRowHeight);

    writer.startElement(HTML.DIV_ELEM, schedule);

    if (cellWidth == 50f) {
        writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "day weekMode"), null);
    } else {
        writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "day monthMode"), null);
    }

    // day header
    writer.startElement(HTML.DIV_ELEM, schedule);

    if (isMonthMode) {
        writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "headerForMonthDay"), null);
    } else if (isWeekMode) {
        writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "headerForWeekDay"), null);
    }

    writer.startElement(HTML.DIV_ELEM, schedule);
    writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "header"), null);
    writer.writeAttribute(HTML.STYLE_ATTR, "height: 18px; width: 100%; overflow: hidden", null);
    writer.writeAttribute(HTML.ID_ATTR, dayHeaderId, null);
    //register an onclick event listener to a day header which will capture
    //the date
    if (!schedule.isReadonly() && schedule.isSubmitOnClick()) {
        writer.writeAttribute(HTML.ONMOUSEUP_ATTR,
                "fireScheduleDateClicked(this, event, '" + formId + "', '" + clientId + "');", null);
    }

    writer.writeText(getDateString(context, schedule, day.getDate()), null);
    writer.endElement(HTML.DIV_ELEM);
    writer.endElement(HTML.DIV_ELEM);

    // day content
    writer.startElement(HTML.DIV_ELEM, schedule);
    writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "contentForMonthDay"), null);
    writer.startElement(HTML.DIV_ELEM, schedule);
    if (isMonthMode) {

        if ((dayOfWeek == Calendar.SUNDAY) || (dayOfWeek == Calendar.SATURDAY)) {
            writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "weekendContent content"), null);
        } else {
            writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "workdayContent content"), null);
        }

    } else {
        if ((dayOfWeek == Calendar.SUNDAY) || (dayOfWeek == Calendar.SATURDAY)) {
            writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "weekendContentWeekMode content"),
                    null);
        } else {
            writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "workdayContentWeekMode content"),
                    null);
        }
    }

    // determine the height of the day content in pixels
    StringBuffer contentStyleBuffer = new StringBuffer();
    contentStyleBuffer.append(myContentHeight);
    //        contentStyleBuffer.append(" width: 100%;");
    writer.writeAttribute(HTML.STYLE_ATTR, contentStyleBuffer.toString(), null);

    writer.startElement(HTML.DIV_ELEM, schedule);
    writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "contentview"), null);

    //this extra div is required, because when a scrollbar is visible and
    //it is clicked, the fireScheduleTimeClicked() method is fired.
    writer.startElement(HTML.DIV_ELEM, schedule);
    writer.writeAttribute(HTML.STYLE_ATTR, "height: 100%; vertical-align: top;", null);

    writer.writeAttribute(HTML.ID_ATTR, dayBodyId, null);

    //register an onclick event listener to a day cell which will capture
    //the date
    if (!schedule.isReadonly() && schedule.isSubmitOnClick()) {
        writer.writeAttribute(HTML.ONMOUSEUP_ATTR,
                "fireScheduleTimeClicked(this, event, '" + formId + "', '" + clientId + "');", null);
    }

    writer.startElement(HTML.DIV_ELEM, schedule);
    writer.writeAttribute(HTML.STYLE_ATTR, "width: 100%;", null);

    writeEntries(context, schedule, day, writer);

    writer.endElement(HTML.DIV_ELEM);
    writer.endElement(HTML.DIV_ELEM);
    writer.endElement(HTML.DIV_ELEM);
    writer.endElement(HTML.DIV_ELEM);
    writer.endElement(HTML.DIV_ELEM);
    writer.endElement(HTML.DIV_ELEM);

    if ((dayOfWeek != Calendar.SATURDAY) && isMonthMode) {
        writer.endElement(HTML.DIV_ELEM);
    }
    if (cellWidth == 50f && dayOfWeek != Calendar.SATURDAY) {
        writer.endElement(HTML.DIV_ELEM);
    }
}

From source file:paarmann.physikprofil.MainActivity.java

public void onBtnTomorrowClick(View view) {
    Calendar cal = Calendar.getInstance();
    int offset;//from w w  w.j a va 2s .co m
    if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {
        offset = 3;
    } else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
        offset = 2;
    } else {
        offset = 1;
    }
    cal.add(Calendar.DAY_OF_MONTH, offset);
    Intent details = new Intent(this, HomeworkDetailActivity.class);
    String date = cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-"
            + cal.get(Calendar.DAY_OF_MONTH);
    details.putExtra(HomeworkDetailActivity.EXTRA_DATE, date);
    startActivity(details);
}

From source file:de.tor.tribes.ui.components.DatePicker.java

/**
 * remaps the days of week of gregorian Calendar to internal values
 *//* ww  w .  ja  v  a  2s  .  c om*/
private int mapDayOfWeek(int cal) {
    switch (cal) {
    case Calendar.MONDAY:
        return 1;
    case Calendar.TUESDAY:
        return 2;
    case Calendar.WEDNESDAY:
        return 3;
    case Calendar.THURSDAY:
        return 4;
    case Calendar.FRIDAY:
        return 5;
    case Calendar.SATURDAY:
        return 6;
    case Calendar.SUNDAY:
        return 7;
    default:
        return 1; //should never happen
    }
}

From source file:com.netflix.simianarmy.basic.BasicCalendar.java

/**
 * Work day in year.//from w  w w. j  a va 2 s.c o  m
 *
 * @param year
 *            the year
 * @param month
 *            the month
 * @param day
 *            the day
 * @return the day of the year adjusted to the closest workday
 */
private int workDayInYear(int year, int month, int day) {
    Calendar holiday = now();
    holiday.set(Calendar.YEAR, year);
    holiday.set(Calendar.MONTH, month);
    holiday.set(Calendar.DAY_OF_MONTH, day);
    int doy = holiday.get(Calendar.DAY_OF_YEAR);
    int dow = holiday.get(Calendar.DAY_OF_WEEK);

    if (dow == Calendar.SATURDAY) {
        return doy - 1; // FRIDAY
    }

    if (dow == Calendar.SUNDAY) {
        return doy + 1; // MONDAY
    }

    return doy;
}

From source file:com.oginotihiro.datepicker.DatePickerDialog.java

public void setFirstDayOfWeek(int startOfWeek) {
    if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) {
        throw new IllegalArgumentException("Value must be between Calendar.SUNDAY and " + "Calendar.SATURDAY");
    }//from   ww  w  . ja v  a2 s .  c  o  m
    mWeekStart = startOfWeek;
    if (mDayPickerView != null) {
        mDayPickerView.onChanged();
    }
}

From source file:cs.umass.edu.prepare.view.custom.CalendarAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;/*from   ww  w .ja  va 2  s.  co  m*/
    TextView dayView;
    if (convertView == null) { // if it's not recycled, initialize some attributes
        v = View.inflate(context, R.layout.calendar_item, null);
    }

    ViewGroup insertPoint = (ViewGroup) v.findViewById(R.id.layout_calendar_item);
    insertPoint.removeAllViews();

    dayView = (TextView) View.inflate(context, R.layout.textview_date, null);
    insertPoint.addView(dayView);

    // disable empty days from the beginning
    if (dateStrings[position].equals("")) {
        dayView.setClickable(false);
        dayView.setFocusable(false);
    } else {
        v.setBackgroundResource(R.drawable.list_item_background);
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, month.get(Calendar.YEAR));
        cal.set(Calendar.MONTH, month.get(Calendar.MONTH));
        cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStrings[position]));
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        if (month.get(Calendar.YEAR) == selectedDate.get(Calendar.YEAR)
                && month.get(Calendar.MONTH) == selectedDate.get(Calendar.MONTH)
                && dateStrings[position].equals("" + selectedDate.get(Calendar.DAY_OF_MONTH))) {
            int selectedColor = ContextCompat.getColor(context,
                    R.color.color_calendar_item_background_selected);
            v.setBackgroundColor(selectedColor);
        } else if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) {
            dayView.setTextColor(Color.GRAY);
        }
    }
    dayView.setText(dateStrings[position]);

    // create date string for comparison
    String dateStr = dateStrings[position];

    if (displayType == DisplayType.BASIC) {
        v.setMinimumHeight(0);
        return v; // do not populate cells
    }
    v.setMinimumHeight(325); // TODO: not device independent

    if (medications == null || adherenceData == null) {
        Log.w(TAG, "Warning : No adherenceData found.");
        return v; // do not populate cells
    }

    if (dateStr.equals(""))
        return v;

    Calendar dateKey = Utils.getDateKey(month.get(Calendar.YEAR), month.get(Calendar.MONTH),
            Integer.parseInt(dateStr));
    if (adherenceData.containsKey(dateKey)) {
        populateCell(dateKey, insertPoint);
    }

    return v;
}

From source file:com.virtusa.akura.attendance.controller.DailyAttendanceController.java

/**
 * Method is to return date list.//  w w  w .j  a  v a  2 s  .  c o  m
 * 
 * @return current date - String
 * @throws AkuraAppException - throw SMSExeption.
 */
@ModelAttribute(MODEL_ATT_CURRENT_DATE)
public List<String> populateDateList() throws AkuraAppException {

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    List<Holiday> holidayList = getHolidayList(String.valueOf(year));
    List<String> dateList = new ArrayList<String>();

    while (true) {
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        if (dayOfWeek == Calendar.SATURDAY) {
            calendar.add(Calendar.DATE, -1);

        } else if (dayOfWeek == Calendar.SUNDAY) {
            calendar.add(Calendar.DATE, CONSTANT_MINUS_TWO);

        } else {

            Date date = calendar.getTime();
            if (!DateUtil.isHoliday(holidayList, DateUtil.getParseDate(DateUtil.getFormatDate(date)))) {
                dateList.add(DateUtil.getFormatDate(date));
                calendar.add(Calendar.DATE, -1);
            } else {
                calendar.add(Calendar.DATE, -1);
            }

        }

        if (dateList.size() == CONSTANT_FIVE) {
            break;
        }

    }

    return dateList;
}

From source file:com.kunze.androidlocaltodo.TaskActivityFragment.java

private void InitializeView(final View rootView) {
    final View activityView = rootView;
    TextWatcher textWatcher = new TextWatcher() {
        @Override/*from   ww w. j av  a  2s  .  co  m*/
        public void afterTextChanged(Editable s) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            TaskChanged(activityView);
        }
    };
    final EditText nameEdit = (EditText) rootView.findViewById(R.id.task_name_edit);
    final TextView nameStatic = (TextView) rootView.findViewById(R.id.task_name_static);
    nameStatic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nameEdit.setVisibility(View.VISIBLE);
            nameStatic.setVisibility(View.INVISIBLE);
        }
    });
    nameEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                nameEdit.setVisibility(View.INVISIBLE);
                nameStatic.setVisibility(View.VISIBLE);
            }
        }
    });
    nameEdit.addTextChangedListener(textWatcher);
    final TextView descriptionEdit = (TextView) rootView.findViewById(R.id.task_description_edit);
    descriptionEdit.addTextChangedListener(textWatcher);

    final TextView dueDateView = (TextView) rootView.findViewById(R.id.due_date_text);
    final DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.due_date_calendar);
    datePicker.init(0, 0, 0, new DatePicker.OnDateChangedListener() {
        @Override
        public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0);
            SetFriendlyDueDateText(dueDateView, calendar);
            TaskChanged(activityView);
        }
    });

    Button todayButton = (Button) rootView.findViewById(R.id.today_button);
    todayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            datePicker.updateDate(now.get(Calendar.YEAR), now.get(Calendar.MONTH),
                    now.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, now);
        }
    });
    Button plusDayButton = (Button) rootView.findViewById(R.id.plus_day_button);
    plusDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 1);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, calendar);
        }
    });
    Button thisWeekendButton = (Button) rootView.findViewById(R.id.this_weekend_button);
    thisWeekendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar weekend = Calendar.getInstance();
            while (weekend.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                weekend.add(Calendar.DATE, 1);
            }
            datePicker.updateDate(weekend.get(Calendar.YEAR), weekend.get(Calendar.MONTH),
                    weekend.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, weekend);
        }
    });
    Button plusWeekButton = (Button) rootView.findViewById(R.id.plus_week_button);
    plusWeekButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
            calendar.add(Calendar.DATE, 7);
            datePicker.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
            SetFriendlyDueDateText(dueDateView, calendar);
        }
    });

    final CheckBox repeatCheck = (CheckBox) rootView.findViewById(R.id.repeat);
    repeatCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            View dialog = (View) buttonView.getParent();
            SetRepeatVisibility(dialog, isChecked);
            TaskChanged(activityView);
        }
    });

    final EditText repeatTimeEdit = (EditText) rootView.findViewById(R.id.repeat_time);
    repeatTimeEdit.addTextChangedListener(textWatcher);

    final Spinner repeatUnitSpinner = (Spinner) rootView.findViewById(R.id.repeat_unit);
    String[] repeatUnits = { "Days", "Weeks", "Months", "Years" };
    repeatUnitSpinner.setAdapter(
            new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, repeatUnits));
    repeatUnitSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (mRow != -1 && mRow != id) {
                TaskChanged(activityView);
            }
            mRow = id;
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            TaskChanged(activityView);
        }

        private long mRow = -1;
    });

    final RadioButton repeatFromComplete = (RadioButton) rootView.findViewById(R.id.repeat_from_complete);
    final RadioButton repeatFromDue = (RadioButton) rootView.findViewById(R.id.repeat_from_due);
    Button revertButton = (Button) rootView.findViewById(R.id.revert_button);
    Button acceptButton = (Button) rootView.findViewById(R.id.accept_button);
    final Button doneButton = (Button) rootView.findViewById(R.id.done_button);
    Button deleteButton = (Button) rootView.findViewById(R.id.delete_button);
    revertButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mNewTask = new Task(mOriginalTask);
            mProgrammaticChange = true;
            InitializeViewFields(activityView, mOriginalTask);
            mProgrammaticChange = false;
            TaskReverted(activityView);
        }
    });
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(doneButton.getContext());
            builder.setTitle("Done?");
            builder.setMessage("Mark task \"" + mNewTask.mName + "\" as done?");
            builder.setNegativeButton("No", null);
            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mNewTask.Done();
                    TaskDatabase db = new TaskDatabase(getActivity());
                    db.SaveTask(mNewTask);
                    InitializeViewFields(rootView, mNewTask);
                }
            });
            builder.show();
        }
    });
}

From source file:com.feilong.commons.core.date.DateUtil.java

/**
 * date ?() <code>23:59:59.999</code> <br>
 * ?:,,?<br>//w  ww . jav  a2s .co  m
 * ?:,?
 * 
 * <pre>
 *   2012-10-11 17:10:30.701 (),
 * return 2012-10-13 23:59:59.999
 * 
 * 
 * getLastDateOfThisWeek(2014-12-31 05:00:00)
 * return 2015-01-03 23:59:59.999
 * </pre>
 * 
 * @param date
 *            ?date
 * @return date ? <code>23:59:59.999</code> 
 * @see #toCalendar(Date)
 * @see Calendar#set(int, int)
 * @see #dayEnd(Calendar)
 * @see Calendar#getTime()
 * @since 1.0.1
 */
public static final Date getLastDateOfThisWeek(Date date) {
    Calendar calendar = toCalendar(date);
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
    dayEnd(calendar);
    return calendar.getTime();
}

From source file:paarmann.physikprofil.MainActivity.java

public void onBtnAfterTomorrowClick(View view) {
    Calendar cal = Calendar.getInstance();
    int offset;// w  w  w .  j a  va2  s.c o m
    if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY
            || cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {
        offset = 4;
    } else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
        offset = 3;
    } else {
        offset = 2;
    }
    cal.add(Calendar.DAY_OF_MONTH, offset);
    Intent details = new Intent(this, HomeworkDetailActivity.class);
    String date = cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-"
            + cal.get(Calendar.DAY_OF_MONTH);
    details.putExtra(HomeworkDetailActivity.EXTRA_DATE, date);
    startActivity(details);
}