List of usage examples for java.util Calendar SUNDAY
int SUNDAY
To view the source code for java.util Calendar SUNDAY.
Click Source Link
From source file:com.asta.app2.tutorial.helloorchestra.ReservationView.java
private boolean isAvailable(Date start, int days) { // the logic here would normally be on some "business service" class rather // than buried here inside the presentation class... // The hotel is closed on sat/sun nights. // Calendar.SUNDAY=1, SATURDAY=6 Calendar cal = Calendar.getInstance(); cal.setTime(start);/*w w w . j a v a2 s. c o m*/ int dow = cal.get(Calendar.DAY_OF_WEEK); if (dow == Calendar.SUNDAY) { return false; } if (dow + days > Calendar.SATURDAY) { return false; } // otherwise, ok return true; }
From source file:com.binary_machinery.avalonschedule.view.schedule.SchedulePagerAdapter.java
@Override public Fragment getItem(int position) { long from = getWeekBeginning(position).getTimeInMillis(); long to = getWeekEnd(position).getTimeInMillis(); Map<Integer, ScheduleRecord> recordsByWeekday = new HashMap<>(7); for (ScheduleRecord record : m_records) { long time = record.date.getTime(); if (from <= time && time <= to) { Calendar c = Calendar.getInstance(); c.setTime(record.date);//from w w w.j a v a 2 s . c o m recordsByWeekday.put(c.get(Calendar.DAY_OF_WEEK), record); } } Calendar calendar = getWeekBeginning(position); for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; ++i) { if (!recordsByWeekday.containsKey(i)) { ScheduleRecord stubRecord = new ScheduleRecord(); calendar.set(Calendar.DAY_OF_WEEK, i); stubRecord.date = calendar.getTime(); stubRecord.weekday = m_context.getResources().getStringArray(R.array.weekdays)[i - 1]; recordsByWeekday.put(i, stubRecord); } } Fragment fragment = new SchedulePageFragment(); Bundle args = new Bundle(); for (Map.Entry<Integer, ScheduleRecord> entry : recordsByWeekday.entrySet()) { int weekdayIdx = entry.getKey(); ScheduleRecord record = entry.getValue(); String key = SchedulePageFragment.ARG_DAY + weekdayIdx; args.putParcelable(key, record); } fragment.setArguments(args); return fragment; }
From source file:org.b3log.symphony.processor.advice.validate.Activity1A0001CollectValidation.java
@Override public void doAdvice(final HTTPRequestContext context, final Map<String, Object> args) throws RequestProcessAdviceException { if (Symphonys.getBoolean("activity1A0001Closed")) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityClosedLabel"))); }// w w w . j av a 2 s. c o m final Calendar calendar = Calendar.getInstance(); final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activity1A0001CloseLabel"))); } final int hour = calendar.get(Calendar.HOUR_OF_DAY); if (hour < 16) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityCollectNotOpenLabel"))); } final HttpServletRequest request = context.getRequest(); JSONObject requestJSONObject; try { requestJSONObject = Requests.parseRequestJSONObject(request, context.getResponse()); request.setAttribute(Keys.REQUEST, requestJSONObject); } catch (final Exception e) { throw new RequestProcessAdviceException(new JSONObject().put(Keys.MSG, e.getMessage())); } final JSONObject currentUser = (JSONObject) request.getAttribute(User.USER); if (null == currentUser) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("reloginLabel"))); } if (UserExt.USER_STATUS_C_VALID != currentUser.optInt(UserExt.USER_STATUS)) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("userStatusInvalidLabel"))); } if (!activityQueryService.is1A0001Today(currentUser.optString(Keys.OBJECT_ID))) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityNotParticipatedLabel"))); } }
From source file:verdandi.model.WeekSelectorModel.java
private String getDateValue(int diff) { Calendar other = (Calendar) cal.clone(); StringBuffer buf = new StringBuffer(); buf.append(WEEK_OF_YEAR_PREFIX);// w ww . j ava 2s.c o m if (diff != 0) { other.add(Calendar.WEEK_OF_YEAR, diff); LOG.debug("Current date: " + cal.getTime() + ", New Date: " + other.getTime() + ", diff: " + diff); } if (other.get(Calendar.WEEK_OF_YEAR) < 10) { buf.append("0"); } buf.append(other.get(Calendar.WEEK_OF_YEAR)); buf.append(": "); other.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); buf.append(dfmt.format(other.getTime())); buf.append(" - "); other.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); buf.append(dfmt.format(other.getTime())); return buf.toString(); }
From source file:org.b3log.symphony.processor.advice.validate.Activity1A0001Validation.java
@Override public void doAdvice(final HTTPRequestContext context, final Map<String, Object> args) throws RequestProcessAdviceException { if (Symphonys.getBoolean("activity1A0001Closed")) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityClosedLabel"))); }/*from w ww .j a v a 2 s. c o m*/ final Calendar calendar = Calendar.getInstance(); final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activity1A0001CloseLabel"))); } final int hour = calendar.get(Calendar.HOUR_OF_DAY); final int minute = calendar.get(Calendar.MINUTE); if (hour > 14 || (hour == 14 && minute > 55)) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityEndLabel"))); } final HttpServletRequest request = context.getRequest(); JSONObject requestJSONObject; try { requestJSONObject = Requests.parseRequestJSONObject(request, context.getResponse()); request.setAttribute(Keys.REQUEST, requestJSONObject); } catch (final Exception e) { throw new RequestProcessAdviceException(new JSONObject().put(Keys.MSG, e.getMessage())); } final int amount = requestJSONObject.optInt(Common.AMOUNT); if (200 != amount && 300 != amount && 400 != amount && 500 != amount) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityBetFailLabel"))); } final int smallOrLarge = requestJSONObject.optInt(Common.SMALL_OR_LARGE); if (0 != smallOrLarge && 1 != smallOrLarge) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityBetFailLabel"))); } final JSONObject currentUser = (JSONObject) request.getAttribute(User.USER); if (null == currentUser) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("reloginLabel"))); } if (UserExt.USER_STATUS_C_VALID != currentUser.optInt(UserExt.USER_STATUS)) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("userStatusInvalidLabel"))); } if (activityQueryService.is1A0001Today(currentUser.optString(Keys.OBJECT_ID))) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("activityParticipatedLabel"))); } final int balance = currentUser.optInt(UserExt.USER_POINT); if (balance - amount < 0) { throw new RequestProcessAdviceException( new JSONObject().put(Keys.MSG, langPropsService.get("insufficientBalanceLabel"))); } }
From source file:org.infoscoop.util.Holiday.java
public int getFreshDays(Calendar cal, int freshDays) { if (isHoliday(cal) || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) { freshDays++;/*ww w. j a v a 2 s. c om*/ cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), (cal.get(Calendar.DATE) - 1)); freshDays = getFreshDays(cal, freshDays); } return freshDays; }
From source file:org.openmrs.module.pharmacyapi.api.prescription.util.NewPrescriptionItemGenerator.java
private Date getExpirationDateMinus2Days(final PrescriptionItem item) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(item.getDrugOrder().getEncounter().getDateCreated()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, 10); while ((calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) || (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)) { calendar.add(Calendar.DAY_OF_MONTH, 1); }/*from w ww.j a va2s . com*/ return calendar.getTime(); }
From source file:com.binary_machinery.avalonschedule.view.schedule.SchedulePageFragment.java
@Nullable @Override/*from www.ja va 2 s. c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.schedule_page, container, false); Bundle arguments = getArguments(); FragmentManager fragmentManager = getChildFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Func2<Integer, Integer, ?> setRecord = (dayOfWeek, layoutId) -> { String key = ARG_DAY + dayOfWeek; ScheduleRecord record = arguments.getParcelable(key); if (record != null) { Fragment fragment = (record.course != null) ? new RecordFragment() : new EmptyRecordFragment(); Bundle args = new Bundle(); args.putParcelable(RecordFragment.ARG_RECORD, record); fragment.setArguments(args); fragmentTransaction.replace(layoutId, fragment); } return 0; }; setRecord.call(Calendar.MONDAY, R.id.layoutMonday); setRecord.call(Calendar.TUESDAY, R.id.layoutTuesday); setRecord.call(Calendar.WEDNESDAY, R.id.layoutWednesday); setRecord.call(Calendar.THURSDAY, R.id.layoutThursday); setRecord.call(Calendar.FRIDAY, R.id.layoutFriday); setRecord.call(Calendar.SATURDAY, R.id.layoutSaturday); setRecord.call(Calendar.SUNDAY, R.id.layoutSunday); fragmentTransaction.commit(); return rootView; }
From source file:com.karthikb351.vitinfo2.fragment.schedule.ScheduleFragment.java
private int getEquivalentDay(int day) { switch (day) { case Calendar.SUNDAY: day = 6;//from w ww. j a v a 2s .c o m break; case Calendar.MONDAY: case Calendar.TUESDAY: case Calendar.WEDNESDAY: case Calendar.THURSDAY: case Calendar.FRIDAY: case Calendar.SATURDAY: day -= 2; break; default: day = 0; } return day; }
From source file:org.ohmage.reminders.types.time.TimeTrigDesc.java
private void initialize(boolean repeatStatus) { mIsRandomized = false;// ww w . j a v a2 s. c o m mIsRangeEnabled = false; mRepeatList.put(getDayOfWeekString(Calendar.SUNDAY), repeatStatus); mRepeatList.put(getDayOfWeekString(Calendar.MONDAY), repeatStatus); mRepeatList.put(getDayOfWeekString(Calendar.TUESDAY), repeatStatus); mRepeatList.put(getDayOfWeekString(Calendar.WEDNESDAY), repeatStatus); mRepeatList.put(getDayOfWeekString(Calendar.THURSDAY), repeatStatus); mRepeatList.put(getDayOfWeekString(Calendar.FRIDAY), repeatStatus); mRepeatList.put(getDayOfWeekString(Calendar.SATURDAY), repeatStatus); }