Example usage for java.util Calendar SUNDAY

List of usage examples for java.util Calendar SUNDAY

Introduction

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

Prototype

int SUNDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Sunday.

Usage

From source file:com.projity.pm.calendar.WorkingCalendar.java

static WorkingCalendar getNightShiftInstance() {
    if (nightShiftInstance != null)
        return nightShiftInstance;
    nightShiftInstance = WorkingCalendar.getStandardBasedInstance();
    WorkDay nonWorking = null;//  w w  w. j a v a 2  s  . c om
    WorkDay working = null;
    nonWorking = new WorkDay();
    working = new WorkDay();
    nonWorking.getWorkingHours().setNonWorking();

    nightShiftInstance.setWeekDay(Calendar.SUNDAY - 1, null); // will revert to overall default for sunday which is not working

    WorkDay monday = new WorkDay();
    try {
        monday.getWorkingHours().setInterval(0, hourTime(23), hourTime(0));
    } catch (WorkRangeException e) {
        e.printStackTrace();
    }
    nightShiftInstance.setWeekDay(Calendar.MONDAY - 1, monday);

    try {
        working.getWorkingHours().setInterval(0, hourTime(0), hourTime(3));
        working.getWorkingHours().setInterval(1, hourTime(4), hourTime(8));
        working.getWorkingHours().setInterval(2, hourTime(23), hourTime(0));
    } catch (WorkRangeException e) {
        e.printStackTrace();
    }
    nightShiftInstance.setWeekDay(Calendar.TUESDAY - 1, working);
    nightShiftInstance.setWeekDay(Calendar.WEDNESDAY - 1, working);
    nightShiftInstance.setWeekDay(Calendar.THURSDAY - 1, working);
    nightShiftInstance.setWeekDay(Calendar.FRIDAY - 1, working);

    WorkDay saturday = new WorkDay();
    try {
        saturday.getWorkingHours().setInterval(0, hourTime(0), hourTime(3));
        saturday.getWorkingHours().setInterval(1, hourTime(4), hourTime(8));
    } catch (WorkRangeException e) {
        e.printStackTrace();
    }
    nightShiftInstance.setWeekDay(Calendar.SATURDAY - 1, saturday);

    nightShiftInstance.setName(Messages.getString("Calendar.NightShift"));
    nightShiftInstance.setFixedId(3);

    CalendarService.getInstance().add(nightShiftInstance); // put night shift calendar in list
    return nightShiftInstance;
}

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

/**
 * Create Category Dataset based on Weight , date start and resource
 * @param start/* www  .j a  va  2  s  . c  o m*/
 * @param resource
 * @return CategoryDataset
 */
protected CategoryDataset createWeightDataset(Timestamp start, MResource rosource) {

    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);
    gc1.clear(Calendar.MINUTE);
    gc1.clear(Calendar.HOUR_OF_DAY);

    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    String nameload = Msg.translate(Env.getCtx(), "Load");
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    String namepossiblecapacity = "Possible Capacity";

    MResourceType t = MResourceType.get(Env.getCtx(), rosource.getS_ResourceType_ID());

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    double currentweight = DB.getSQLValue(null,
            "SELECT SUM( (mo.qtyordered-mo.qtydelivered)*(SELECT mp.weight FROM M_Product mp WHERE  mo.m_product_id=mp.m_product_id )) FROM PP_Order mo WHERE AD_Client_ID=?",
            rosource.getAD_Client_ID());
    double dailyCapacity = rosource.getDailyCapacity().doubleValue();
    double utilization = rosource.getPercentUtilization().doubleValue();
    double summary = 0;

    int day = 0;
    while (day < 32) {

        day++;
        switch (gc1.get(Calendar.DAY_OF_WEEK)) {

        case Calendar.SUNDAY:

            if (t.isOnSunday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.MONDAY:

            if (t.isOnMonday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.TUESDAY:

            if (t.isOnTuesday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.WEDNESDAY:

            if (t.isOnWednesday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.THURSDAY:

            if (t.isOnThursday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.FRIDAY:

            if (t.isOnFriday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;

        case Calendar.SATURDAY:

            if (t.isOnSaturday()) {

                currentweight -= (dailyCapacity * utilization) / 100;
                summary += ((dailyCapacity * utilization) / 100);

                dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day));
                dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day));
            } else {

                dataset.addValue(0, namepossiblecapacity, new Integer(day));
                dataset.addValue(0, namecapacity, new Integer(day));
            }

            break;
        }

        dataset.addValue(currentweight, nameload, new Integer(day));
        dataset.addValue(summary, namesummary, new Integer(day));

        gc1.add(Calendar.DATE, 1);
    }
    return dataset;
}

From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java

/**
 * Implementation of LoaderCallbacks//from w w w. j a va2  s .  com
 */
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle arg1) {

    final GregorianCalendar parkingCalendar = parkingApp.getParkingCalendar();

    final int dayOfWeek = (parkingCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY ? 7
            : parkingCalendar.get(Calendar.DAY_OF_WEEK) - 1);
    final double parkingHour = parkingCalendar.get(Calendar.HOUR_OF_DAY)
            + Math.round(parkingCalendar.get(Calendar.MINUTE) / 0.6) / 100.00d;

    final double hourOfWeek = parkingHour + (dayOfWeek - 1) * 24;

    // API uses values 0-365 (or 364)
    final int dayOfYear = parkingCalendar.get(Calendar.DAY_OF_YEAR) - 1;

    final int duration = parkingApp.getParkingDuration();

    final Uri uriPost = Posts.buildPostTimedUri(String.valueOf(mIdPost), String.valueOf(hourOfWeek),
            String.valueOf(hourOfWeek + duration), String.valueOf(dayOfYear));

    return new CursorLoader(getSherlockActivity().getApplicationContext(), uriPost, PostDetailsQuery.PROJECTION,
            null, new String[] { Double.toString(hourOfWeek), Integer.toString(duration),
                    Integer.toString(dayOfYear) },
            null);
}

From source file:org.sakaiproject.tool.summarycalendar.ui.CalendarBean.java

private CalendarEventVector getEventsFromSchedule() {
    if (calendarEventVector == null) {
        Calendar firstDay;//from ww  w  .j av a2s  . c om
        Calendar lastDay;

        if (viewMode.equals(MODE_WEEKVIEW)) {
            // WEEK VIEW

            // select first day
            firstDay = Calendar.getInstance(getCurrentUserTimezone(), msgs.getLocale());
            firstDay.setTime(getViewingDate());
            firstDay.set(Calendar.HOUR_OF_DAY, 0);
            firstDay.set(Calendar.MINUTE, 0);
            firstDay.set(Calendar.SECOND, 0);
            firstDay.set(Calendar.MILLISECOND, 0);
            int dayOfWeek = firstDay.get(Calendar.DAY_OF_WEEK);
            // TODO Allow dynamic choice of first day of week
            while (dayOfWeek != Calendar.SUNDAY) {
                firstDay.add(Calendar.DAY_OF_WEEK, -1);
                dayOfWeek = firstDay.get(Calendar.DAY_OF_WEEK);
            }

            // select last day
            lastDay = (Calendar) firstDay.clone();
            lastDay.add(Calendar.DAY_OF_WEEK, 6);
            lastDay.set(Calendar.HOUR_OF_DAY, 23);
            lastDay.set(Calendar.MINUTE, 59);
            lastDay.set(Calendar.SECOND, 59);
            lastDay.set(Calendar.MILLISECOND, 999);
        } else {
            // MONTH VIEW

            // select first day
            firstDay = Calendar.getInstance(getCurrentUserTimezone(), msgs.getLocale());
            firstDay.setTime(getViewingDate());
            int selYear = firstDay.get(Calendar.YEAR);
            int selMonth = firstDay.get(Calendar.MONTH);
            firstDay.set(Calendar.YEAR, selYear);
            firstDay.set(Calendar.DAY_OF_MONTH, 1);
            firstDay.set(Calendar.HOUR_OF_DAY, 0);
            firstDay.set(Calendar.MINUTE, 0);
            firstDay.set(Calendar.SECOND, 0);
            firstDay.set(Calendar.MILLISECOND, 0);
            int dayOfWeek = firstDay.get(Calendar.DAY_OF_WEEK);
            // TODO Allow dynamic choice of first day of week
            while (dayOfWeek != Calendar.SUNDAY) {
                firstDay.add(Calendar.DAY_OF_WEEK, -1);
                dayOfWeek = firstDay.get(Calendar.DAY_OF_WEEK);
            }

            // select last day
            lastDay = (Calendar) firstDay.clone();
            lastDay.set(Calendar.YEAR, selYear);
            lastDay.set(Calendar.MONTH, selMonth);
            lastDay.set(Calendar.DAY_OF_MONTH, lastDay.getActualMaximum(Calendar.DAY_OF_MONTH));
            lastDay.set(Calendar.HOUR_OF_DAY, 23);
            lastDay.set(Calendar.MINUTE, 59);
            lastDay.set(Calendar.SECOND, 59);
            lastDay.set(Calendar.MILLISECOND, 999);
            dayOfWeek = lastDay.get(Calendar.DAY_OF_WEEK);
            // TODO Allow dynamic choice of first day of week
            while (dayOfWeek != Calendar.SATURDAY) {
                lastDay.add(Calendar.DAY_OF_WEEK, 1);
                dayOfWeek = lastDay.get(Calendar.DAY_OF_WEEK);
            }
        }

        Time firstTime = M_ts.newTime(firstDay.getTimeInMillis());
        Time lastTime = M_ts.newTime(lastDay.getTimeInMillis());
        TimeRange range = M_ts.newTimeRange(firstTime, lastTime);
        calendarEventVector = M_ca.getEvents(getCalendarReferences(), range);
    }
    return calendarEventVector;
}

From source file:fr.paris.lutece.plugins.calendar.service.Utils.java

/**
 * Checks if the day if Off (ie: Sunday) or not
 * @param calendar A calendar object positionned on the day to check
 * @return True if the day if Off, otherwise false
 *//*from   ww w.j  ava 2s  .  com*/
public static boolean isDayOff(Calendar calendar) {
    int nDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);

    if ((nDayOfWeek == Calendar.SATURDAY) || (nDayOfWeek == Calendar.SUNDAY)) {
        return true;
    }

    // Add other checks here
    return false;
}

From source file:com.virtusa.akura.student.controller.StudentAttendenceController.java

/**
 * get all days without special holidays and Saturday,Sunday for given Date range. map key contains date
 * and value contains AttendeceStatus object with default values(as absent day)
 * /*from w ww .ja va 2 s  .c  o m*/
 * @param from from date
 * @param to to date
 * @return map
 * @throws AkuraAppException when exception occurs
 */
private Map<String, AttendeceStatus> getDaysWithoutHolydays(Date from, Date to) throws AkuraAppException {

    Calendar calFrom = Calendar.getInstance();
    Calendar calTo = Calendar.getInstance();

    calFrom.setTime(from);
    calTo.setTime(to);

    List<Holiday> holidayList = commonService.findHolidayByYear(from, to);

    Map<String, AttendeceStatus> allDaysBetween = new TreeMap<String, AttendeceStatus>();

    // to get name ex Sunday ,Monday ..
    DateFormatSymbols symbols = new DateFormatSymbols();
    String[] weekDays = symbols.getWeekdays();

    while (calFrom.before(calTo) || calFrom.equals(calTo)) {

        int dyaOfWeek = calFrom.get(Calendar.DAY_OF_WEEK);
        // remove weekends and special holidays
        if (dyaOfWeek != Calendar.SATURDAY && dyaOfWeek != Calendar.SUNDAY
                && !DateUtil.isHoliday(holidayList, calFrom.getTime())) {

            AttendeceStatus attSttus = new AttendeceStatus();
            attSttus.setDay(weekDays[dyaOfWeek]);
            allDaysBetween.put(DateUtil.getFormatDate(calFrom.getTime()), attSttus);
        }

        calFrom.set(Calendar.DATE, calFrom.get(Calendar.DATE) + 1);
    }

    return allDaysBetween;
}

From source file:com.provision.alarmemi.paper.fragments.SetAlarmFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    mActivity.setOnLifeCycleChangeListener(this);

    isChanged = isCloud = false;/*from  w  w w .j a v a  2s. c  o  m*/
    // Override the default content view.
    root = (ViewGroup) super.onCreateView(inflater, container, bundle);
    final ImageView moreAlarm = (ImageView) root.findViewById(R.id.more_alarm);
    FragmentChangeActivity.moreAlarm = moreAlarm;
    moreAlarm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (menu.isMenuShowing()) {
                menu.showContent();
            } else {
                menu.showMenu(true);
            }
        }
    });
    // Make the entire view selected when focused.
    moreAlarm.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            v.setSelected(hasFocus);
        }
    });

    addPreferencesFromResource(R.xml.alarm_prefs);
    myUUID = SplashActivity.myUUID;

    // Get each preference so we can retrieve the value later.
    mLabel = findPreference("label");
    mLabel.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showEditTextPreference(mLabel.getKey(), mLabel.getTitle(), mLabelText);
            return true;
        }
    });

    Preference.OnPreferenceChangeListener preferceChangedListener = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference p, Object newValue) {
            isChanged = true;
            return true;
        }
    };

    mEnabledPref = (CheckBoxPreference) findPreference("enabled");
    mEnabledPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (!isCloud) {
                isChanged = true;
                if ((Boolean) newValue)
                    showCategory();
                else
                    hideCategory();
                return true;
            }
            if ((Boolean) newValue) {
                try {
                    tempjson = new JSONArray("[]");
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                selectedDevice = "";
                for (int i = 0; i < json.length(); i++) {
                    if (UIDitems[i].toString().equals(myUUID))
                        checkedItems[i] = true;
                    if (checkedItems[i]) {
                        Map<String, String> map = new HashMap<String, String>();
                        map.put("name", URLDecoder.decode(items[i].toString()));
                        map.put("uid", UIDitems[i].toString());
                        tempjson.put(map);
                        selectedDevice += items[i] + ", ";
                    }
                }
                if (!selectedDevice.equals(""))
                    selectedDevice = selectedDevice.substring(0, selectedDevice.length() - 2);
            } else {
                try {
                    tempjson = new JSONArray("[]");
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                selectedDevice = "";
                for (int i = 0; i < json.length(); i++) {
                    if (UIDitems[i].toString().equals(myUUID))
                        checkedItems[i] = false;
                    if (checkedItems[i]) {
                        Map<String, String> map = new HashMap<String, String>();
                        map.put("name", URLDecoder.decode(items[i].toString()));
                        map.put("uid", UIDitems[i].toString());
                        tempjson.put(map);
                        selectedDevice += items[i] + ", ";
                    }
                }
                if (!selectedDevice.equals(""))
                    selectedDevice = selectedDevice.substring(0, selectedDevice.length() - 2);
            }
            mForest.setSummary(selectedDevice);
            isChanged = true;
            return true;
        }
    });
    mTimePref = findPreference("time");
    mVibratePref = (CheckBoxPreference) findPreference("vibrate");
    mVibratePref.setOnPreferenceChangeListener(preferceChangedListener);
    mRepeatPref = findPreference("setRepeat");
    mRepeatPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] values = new String[] {
                    DateUtils.getDayOfWeekString(Calendar.MONDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.TUESDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.WEDNESDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.THURSDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.FRIDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.SATURDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_LONG) };
            Intent intent = new Intent(mActivity, RepeatListPreference.class);
            intent.putExtra("key", mRepeatPref.getKey());
            intent.putExtra("title", mRepeatPref.getTitle());
            intent.putExtra("lists", values);
            intent.putExtra("multi", true);
            startActivity(intent);
            return true;
        }
    });
    mForestName = findPreference("forest_name");
    mForest = findPreference("forest");
    mColorPref = (AmbilWarnaPreference) findPreference("color");
    prefs = mActivity.getSharedPreferences("forest", mActivity.MODE_PRIVATE);

    Intent i = mActivity.setAlarmGetIntent;
    mId = i.getIntExtra(Alarms.ALARM_ID, -1);

    alarm = null;
    if (mId == -1) {
        // No alarm id means create a new alarm.
        alarm = new Alarm();
        isChanged = true;
    } else {
        // * load alarm details from database
        alarm = Alarms.getAlarm(mActivity.getContentResolver(), mId);
        // Bad alarm, bail to avoid a NPE.
        if (alarm == null) {
            finish();
            return root;
        }
        isCloud = wasCloud = alarm.cloudEnabled;
    }
    mOriginalAlarm = alarm;

    if (wasCloud) {
        try {
            Log.e("url", " : " + alarm.cloudName);
            json = new JSONArray(prefs.getString(alarm.cloudName + "_registeredDevice", ""));
            String cloud_uid = alarm.cloudUID;
            if (cloud_uid.equals(""))
                cloud_uid = "[]";
            Log.e("url", cloud_uid);
            tempjson = new JSONArray(cloud_uid);
            items = new String[json.length()];
            UIDitems = new CharSequence[json.length()];
            checkedItems = new boolean[json.length()];
            for (int j = 0; j < json.length(); j++) {
                JSONObject jsonObj = json.getJSONObject(j);
                items[j] = jsonObj.getString("name");
                UIDitems[j] = jsonObj.getString("uid");
                checkedItems[j] = alarm.cloudUID.contains(jsonObj.getString("uid"));
            }
        } catch (Exception e) {
            Log.e("url", e.toString());
        }
        selectedDevice = alarm.cloudDevices;
        mForestName.setEnabled(false);
    } else {
        if (prefs.getString("name", "").length() > 0) {
            names = prefs.getString("name", "").substring(1).split("\\|");
            nameCheckedIndex = -1;
        } else
            mForestName.setEnabled(false);
        mForest.setEnabled(false);
    }
    memi_count = alarm.memiCount;
    snooze_strength = alarm.snoozeStrength;
    snooze_count = alarm.snoozeCount;

    updatePrefs(mOriginalAlarm);

    mTimePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {
            showTimePicker();
            return false;
        }

    });

    mForestName.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showListPreference(mForestName.getKey(), mForestName.getTitle(), names,
                    String.valueOf(nameCheckedIndex), false);
            return true;
        }
    });

    mForest.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            showListPreference(mForest.getKey(), mForest.getTitle(), items, booleanArrayToString(checkedItems),
                    true);
            return true;
        }
    });
    mColorPref.setOnPreferenceChangeListener(preferceChangedListener);

    // We have to do this to get the save/cancel buttons to highlight on
    // their own.
    ((ListView) root.findViewById(android.R.id.list)).setItemsCanFocus(true);

    // Attach actions to each button.
    View.OnClickListener back_click = new View.OnClickListener() {
        public void onClick(View v) {
            DontSaveDialog(false, null, false);
        }
    };
    ImageView b = (ImageView) root.findViewById(R.id.back);
    b.setOnClickListener(back_click);

    b = (ImageView) root.findViewById(R.id.logo);
    b.setOnClickListener(back_click);

    b = (ImageView) root.findViewById(R.id.alarm_save);
    b.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            saveAlarm();
        }
    });
    b = (ImageView) root.findViewById(R.id.alarm_delete);
    if (mId == -1) {
        b.setEnabled(false);
    } else {
        b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                deleteAlarm();
            }
        });
    }

    // The last thing we do is pop the time picker if this is a new alarm.
    if (mId == -1) {
        // Assume the user hit cancel
        mTimePickerCancelled = true;
        showTimePicker();
    }

    if (!isCloud && !alarm.enabled)
        hideCategory();

    FragmentChangeActivity.OnNotifyArrived.sendEmptyMessage(0);
    return root;
}

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

private void renderAllDayGrid(final int year, final int weekOfYear, final List sortedAllDayEventsForWeek,
        final StringOutput sb, final URLBuilder ubu, final Translator translator) {
    final Calendar cal = CalendarUtils.getStartOfWeekCalendar(year, weekOfYear, translator.getLocale());
    int dayToday = -1;
    final Calendar calNow = CalendarUtils.createCalendarInstance(translator.getLocale());
    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);
    }/* w ww.ja  va2s . c  o  m*/

    final StringOutput inset = new StringOutput(1024);
    int maxDayEvents = 0;
    for (int day = 1; day <= days; day++) {
        final int dayOfWeekIter = cal.get(Calendar.DAY_OF_WEEK);
        final Date periodBegin = cal.getTime();
        inset.append("<div class=\"o_cal_wv_dlday o_cal_wv_row");
        inset.append(day);
        if (dayOfWeekIter == dayToday) {
            // current day
            inset.append(" o_cal_wv_today");
        } else if (dayOfWeekIter == Calendar.SATURDAY || dayOfWeekIter == Calendar.SUNDAY) {
            // holiday
            inset.append(" o_cal_wv_holiday");
        }
        if (day == days) {
            // last day
            inset.append(" o_cal_wv_lastday");
        }
        inset.append("\" style=\"height: 100%;\">");

        cal.add(Calendar.DAY_OF_YEAR, 1);
        final Date periodEnd = cal.getTime();
        // render daylong events
        int maxDayEventsThisDay = 0;
        for (final Iterator iter = sortedAllDayEventsForWeek.iterator(); iter.hasNext();) {
            final KalendarEventRenderWrapper eventWrapper = (KalendarEventRenderWrapper) iter.next();
            final KalendarEvent event = eventWrapper.getEvent();
            // skip if not within period
            if (event.getEnd().compareTo(periodBegin) < 0 || event.getBegin().compareTo(periodEnd) >= 0) {
                continue;
            }
            // increment count of number of dayevents
            maxDayEventsThisDay++;
            final boolean hideSubject = eventWrapper
                    .getCalendarAccess() == KalendarRenderWrapper.ACCESS_READ_ONLY
                    && !eventWrapper.getKalendarRenderWrapper().isImported()
                    && event.getClassification() != KalendarEvent.CLASS_PUBLIC;
            final String escapedSubject = Formatter.escWithBR(event.getSubject()).toString();

            inset.append("<div class=\"o_cal_wv_devent_wrapper\">");
            inset.append("<div class=\"o_cal_wv_devent ")
                    .append(eventWrapper.getKalendarRenderWrapper().getKalendarConfig().getCss()).append("\">");
            inset.append("<div class=\"o_cal_wv_devent_content\">");
            inset.append("<a href=\"");
            ubu.buildURI(inset,
                    new String[] { WeeklyCalendarComponent.ID_CMD, WeeklyCalendarComponent.ID_PARAM },
                    new String[] { WeeklyCalendarComponent.CMD_EDIT,
                            event.getCalendar().getCalendarID() + WeeklyCalendarComponent.ID_PARAM_SEPARATOR
                                    + event.getID() + WeeklyCalendarComponent.ID_PARAM_SEPARATOR
                                    + event.getBegin().getTime() },
                    isIframePostEnabled ? AJAXFlags.MODE_TOBGIFRAME : AJAXFlags.MODE_NORMAL);
            inset.append("\" ");
            if (isIframePostEnabled) {
                ubu.appendTarget(inset);
            }
            inset.append(" onclick=\"return o2cl();\">");
            if (hideSubject) {
                inset.append("<i>").append(translator.translate("cal.eventdetails.hidden")).append("</i>");
            } else {
                inset.append(escapedSubject);
            }
            inset.append("</a>");
            // append any event links
            if (!hideSubject) {
                renderEventLinks(event, inset);
            }
            // closing devent_content
            inset.append("</div>");

            // render event tooltip content
            renderEventTooltip(eventWrapper, escapedSubject, hideSubject, inset, ubu, translator.getLocale());

            // closing devent and devent_wrapper
            inset.append("</div></div>");
        } // events within day iterator

        inset.append("</div>");
        if (maxDayEventsThisDay > maxDayEvents) {
            maxDayEvents = maxDayEventsThisDay;
        }
    } // day irterator

    // do not render anything if we do not have any allday events
    if (maxDayEvents == 0) {
        return;
    }
    sb.append("\n<div id=\"o_cal_wv_daylong\" style=\"height: ").append(maxDayEvents * dayEventHeightPixels)
            .append("px;\">");
    sb.append("<div class=\"o_cal_wv_time o_cal_wv_row0\" style=\"height: 100%;\"></div>");
    sb.append(inset);
    sb.append("</div>");
}

From source file:com.android.datetimepicker.date.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   w  ww.java2s  .c o m
    mWeekStart = startOfWeek;
    if (mDayPickerView != null) {
        mDayPickerView.onChange();
    }
}

From source file:org.activequant.util.charting.IntradayMarketTimeline.java

private long getActiveTimePerDay(int day) {
    long closedTime = 0;

    if (day == Calendar.SUNDAY) {
        closedTime = this.sundayActive;
    } else if (day == Calendar.MONDAY) {
        closedTime = this.mondayActive;
    } else if (day == Calendar.TUESDAY) {
        closedTime = this.tuesdayActive;
    } else if (day == Calendar.WEDNESDAY) {
        closedTime = this.wednesdayActive;
    } else if (day == Calendar.THURSDAY) {
        closedTime = this.thursdayActive;
    } else if (day == Calendar.FRIDAY) {
        closedTime = this.fridayActive;
    } else if (day == Calendar.SATURDAY) {
        closedTime = this.saturdayActive;
    }//from  w  ww .  jav  a 2 s .  com

    return closedTime;
}