List of usage examples for java.util Calendar SATURDAY
int SATURDAY
To view the source code for java.util Calendar SATURDAY.
Click Source Link
From source file:com.android.calendar.month.MonthByWeekFragment.java
@Override protected void setUpHeader() { if (mIsMiniMonth) { super.setUpHeader(); return;/*from w w w. ja va2 s . c o m*/ } mDayLabels = new String[7]; for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) { mDayLabels[i - Calendar.SUNDAY] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase(); } }
From source file:org.kuali.coeus.common.committee.impl.bo.CommitteeScheduleBase.java
/** * This UI support method to find day Of week from BO's persistent field scheduledDate. * @return// w ww. jav a2s. c o m */ public String getDayOfWeek() { Calendar cl = new GregorianCalendar(); cl.setTime(scheduledDate); DayOfWeek dayOfWeek = null; switch (cl.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: dayOfWeek = DayOfWeek.Sunday; break; case Calendar.MONDAY: dayOfWeek = DayOfWeek.Monday; break; case Calendar.TUESDAY: dayOfWeek = DayOfWeek.Tuesday; break; case Calendar.WEDNESDAY: dayOfWeek = DayOfWeek.Wednesday; break; case Calendar.THURSDAY: dayOfWeek = DayOfWeek.Thursday; break; case Calendar.FRIDAY: dayOfWeek = DayOfWeek.Friday; break; case Calendar.SATURDAY: dayOfWeek = DayOfWeek.Saturday; break; } return dayOfWeek.name().toUpperCase(); }
From source file:CalendarUtils.java
/** * This constructs an Iterator that will start and stop over a date * range based on the focused date and the range style. For instance, * passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return * an Iterator that starts with Sunday, June 30, 2002 and ends with * Saturday, August 3, 2002./* ww w .ja va 2s. c om*/ */ public static Iterator getCalendarIterator(Calendar focus, int rangeStyle) { Calendar start = null; Calendar end = null; int startCutoff = Calendar.SUNDAY; int endCutoff = Calendar.SATURDAY; switch (rangeStyle) { case RANGE_MONTH_SUNDAY: case RANGE_MONTH_MONDAY: //Set start to the first of the month start = trunc(focus, Calendar.MONTH); //Set end to the last of the month end = (Calendar) start.clone(); end.add(Calendar.MONTH, 1); end.add(Calendar.DATE, -1); //Loop start back to the previous sunday or monday if (rangeStyle == RANGE_MONTH_MONDAY) { startCutoff = Calendar.MONDAY; endCutoff = Calendar.SUNDAY; } break; case RANGE_WEEK_SUNDAY: case RANGE_WEEK_MONDAY: case RANGE_WEEK_RELATIVE: case RANGE_WEEK_CENTER: //Set start and end to the current date start = trunc(focus, Calendar.DATE); end = trunc(focus, Calendar.DATE); switch (rangeStyle) { case RANGE_WEEK_SUNDAY: //already set by default break; case RANGE_WEEK_MONDAY: startCutoff = Calendar.MONDAY; endCutoff = Calendar.SUNDAY; break; case RANGE_WEEK_RELATIVE: startCutoff = focus.get(Calendar.DAY_OF_WEEK); endCutoff = startCutoff - 1; break; case RANGE_WEEK_CENTER: startCutoff = focus.get(Calendar.DAY_OF_WEEK) - 3; endCutoff = focus.get(Calendar.DAY_OF_WEEK) + 3; break; } break; default: throw new RuntimeException("The range style " + rangeStyle + " is not valid."); } if (startCutoff < Calendar.SUNDAY) { startCutoff += 7; } if (endCutoff > Calendar.SATURDAY) { endCutoff -= 7; } while (start.get(Calendar.DAY_OF_WEEK) != startCutoff) { start.add(Calendar.DATE, -1); } while (end.get(Calendar.DAY_OF_WEEK) != endCutoff) { end.add(Calendar.DATE, 1); } final Calendar startFinal = start; final Calendar endFinal = end; Iterator it = new Iterator() { Calendar spot = null; { spot = startFinal; spot.add(Calendar.DATE, -1); } public boolean hasNext() { return spot.before(endFinal); } public Object next() { if (spot.equals(endFinal)) { throw new NoSuchElementException(); } spot.add(Calendar.DATE, 1); return spot.clone(); } public void remove() { throw new UnsupportedOperationException(); } }; return it; }
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 */// w w w. j ava 2s . c o m 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 ww w .j ava 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 2 s . c om // 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); }//from w w w. j av a 2 s . 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:org.callistasoftware.netcare.core.spi.HealthPlanServiceTest.java
@Test @Transactional/* w w w .j a v a2 s.c om*/ @Rollback(true) public void testAddActivityDefintion() throws Exception { final CountyCouncilEntity cc = ccRepo.save(CountyCouncilEntity.newEntity(CountyCouncil.STOCKHOLM)); final ActivityCategoryEntity cat = this.catRepo.save(ActivityCategoryEntity.newEntity("Fysisk aktivitet")); final CareUnitEntity cu = CareUnitEntity.newEntity("cu", cc); this.cuRepo.save(cu); final ActivityTypeEntity type = ActivityTypeEntity.newEntity("Lpning", cat, cu, AccessLevel.CAREUNIT); MeasurementTypeEntity.newEntity(type, "Distans", MeasurementValueType.SINGLE_VALUE, newMeasureUnit("m", "Meter", cc), false, 0); MeasurementTypeEntity me = MeasurementTypeEntity.newEntity(type, "Vikt", MeasurementValueType.INTERVAL, newMeasureUnit("kg", "Kilogram", cc), true, 1); final ActivityTypeEntity savedType = typeRepo.saveAndFlush(type); final CareActorEntity ca = CareActorEntity.newEntity("Test Testgren", "", "hsa-123", cu); final CareActorEntity savedCa = this.careActorRepo.save(ca); final PatientEntity patient = PatientEntity.newEntity("Marcus Krantz", "", "123456789004"); final PatientEntity savedPatient = this.patientRepo.save(patient); // the date and duration can't be changed without breaking the test, see // further below. final HealthPlanEntity ord = HealthPlanEntity.newEntity(savedCa, savedPatient, "Test", ApiUtil.parseDate("2012-12-01"), 12, DurationUnit.WEEK); final HealthPlanEntity savedOrd = this.ordinationRepo.save(ord); final ActivityTypeImpl typeImpl = new ActivityTypeImpl(); typeImpl.setId(savedType.getId()); typeImpl.setName("Lpning"); final ActivityItemTypeImpl mdType = new ActivityItemTypeImpl(); mdType.setId(me.getId()); mdType.setName(me.getName()); final MeasurementDefinitionImpl md = new MeasurementDefinitionImpl(); md.setTarget(1200); md.setActivityItemType(mdType); final ActivityDefinitionImpl impl = new ActivityDefinitionImpl(); impl.setHealthPlanId(savedOrd.getId()); impl.setType(typeImpl); impl.setActivityRepeat(2); impl.setGoalValues(new MeasurementDefinitionImpl[] { md }); // Monday and saturday final DayTimeImpl dt = new DayTimeImpl(); dt.setDay("monday"); dt.setTimes(new String[] { "12:15", "18:45" }); final DayTimeImpl dt2 = new DayTimeImpl(); dt2.setDay("saturday"); dt2.setTimes(new String[] { "12:15", "18:45" }); final DayTimeImpl[] dts = new DayTimeImpl[2]; dts[0] = dt; dts[1] = dt2; impl.setDayTimes(dts); final CareActorBaseView cabv = CareActorBaseViewImpl.newFromEntity(savedCa); this.runAs(cabv); final ServiceResult<ActivityDefinition> result = this.service.addActvitiyToHealthPlan(impl); assertTrue(result.isSuccess()); final ActivityDefinitionImpl impl2 = new ActivityDefinitionImpl(); impl2.setHealthPlanId(savedOrd.getId()); impl2.setType(typeImpl); impl2.setActivityRepeat(0); impl2.setStartDate("2013-01-30"); impl2.setGoalValues(new MeasurementDefinitionImpl[] { md }); // Wednesday (1 time activity) final DayTimeImpl dt3 = new DayTimeImpl(); dt3.setDay("wednesday"); dt3.setTimes(new String[] { "07:15", "12:00", "22:45" }); impl2.setDayTimes(new DayTimeImpl[] { dt3 }); this.runAs(CareActorBaseViewImpl.newFromEntity(ca)); final ServiceResult<ActivityDefinition> result2 = this.service.addActvitiyToHealthPlan(impl2); assertTrue(result2.isSuccess()); this.schedRepo.flush(); this.ordinationRepo.flush(); final HealthPlanEntity after = this.ordinationRepo.findOne(savedOrd.getId()); final ActivityDefinitionEntity ent = after.getActivityDefinitions().get(0); // FIXME: multi-values assertEquals(newMeasureUnit("m", "Meter", cc), ((MeasurementTypeEntity) ent.getActivityItemDefinitions().get(0).getActivityItemType()).getUnit()); assertEquals("Lpning", ent.getActivityType().getName()); // FIXME: multi-values // assertEquals(12, ent.getActivityTarget()); final Frequency fr = ent.getFrequency(); final List<FrequencyTime> times = fr.getDay(Calendar.MONDAY).getTimes(); assertEquals(2, times.size()); assertEquals("2012-12-01", ApiUtil.formatDate(after.getStartDate())); assertEquals(12, times.get(0).getHour()); assertEquals(15, times.get(0).getMinute()); assertEquals(18, times.get(1).getHour()); assertEquals(45, times.get(1).getMinute()); assertTrue(fr.isDaySet(Calendar.MONDAY)); assertTrue(fr.isDaySet(Calendar.SATURDAY)); assertEquals(2, fr.getWeekFrequency()); assertEquals("7,12:15,18:45", FrequencyDay.marshal(fr.getDay(Calendar.SATURDAY))); // check Date startDate = after.getStartDate(); Date endDate = after.getEndDate(); List<ScheduledActivityEntity> scheduledActivities = schedRepo .findByPatientAndScheduledTimeBetween(savedPatient, startDate, endDate); Collections.sort(scheduledActivities); int n = scheduledActivities.size(); // 26 (every other week * 2) + 3 (single day * 3) assertEquals(29, n); assertEquals("2013-02-23", ApiUtil.formatDate(scheduledActivities.get(n - 1).getScheduledTime())); }
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"); }/* w w w .j ava2s . co m*/ mWeekStart = startOfWeek; if (mDayPickerView != null) { mDayPickerView.onChange(); } }
From source file:com.alkacon.opencms.calendar.CmsCalendarMonthBean.java
/** * Returns the days of a month to display in a matrix, depending on the start day of the week.<p> * //from w w w. j ava 2 s . c o m * The month matrix starts with index "1" and uses 7 columns per row to display one week in a row. * The value returns null if no date should be shown at the current index position.<p> * * @param year the year of the month to display * @param month the month to display * @param calendarLocale the Locale for the calendar to determine the start day of the week * @return the days of a month to display in a matrix, depending on the start day of the week */ public Map getMonthDaysMatrix(int year, int month, Locale calendarLocale) { Map monthDays = new TreeMap(); Calendar startDay = new GregorianCalendar(year, month, 1); Calendar runDay = startDay; int index = 1; // calculate the start day of the week Calendar calendar = new GregorianCalendar(calendarLocale); int weekStart = calendar.getFirstDayOfWeek(); // create empty indexes before the first day of the month while (runDay.get(Calendar.DAY_OF_WEEK) != weekStart) { monthDays.put(new Integer(index), null); index++; if (weekStart == Calendar.SATURDAY) { weekStart = Calendar.SUNDAY; } else { weekStart++; } } // create the indexes for the month dates while (true) { monthDays.put(new Integer(index), runDay.clone()); // increase day to next day runDay.roll(Calendar.DAY_OF_MONTH, true); index++; if (runDay.get(Calendar.DAY_OF_MONTH) == 1) { // runDay has switched to the next month, stop loop break; } } // create empty indexes after the last day of the month int rest = (index - 1) % 7; if (rest > 0) { rest = 7 - rest; } for (int i = 0; i < rest; i++) { monthDays.put(new Integer(index), null); index++; } return monthDays; }