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:Main.java
/** * Converts the day of the week from android.text.format.Time to java.util.Calendar *//* w ww . j a v a2s.c om*/ public static int convertDayOfWeekFromTimeToCalendar(int timeDayOfWeek) { switch (timeDayOfWeek) { case Time.MONDAY: return Calendar.MONDAY; case Time.TUESDAY: return Calendar.TUESDAY; case Time.WEDNESDAY: return Calendar.WEDNESDAY; case Time.THURSDAY: return Calendar.THURSDAY; case Time.FRIDAY: return Calendar.FRIDAY; case Time.SATURDAY: return Calendar.SATURDAY; case Time.SUNDAY: return Calendar.SUNDAY; default: throw new IllegalArgumentException("Argument must be between Time.SUNDAY and " + "Time.SATURDAY"); } }
From source file:Main.java
/** * Get first day of week as android.text.format.Time constant. * * @return the first day of week in android.text.format.Time *///from w w w . j av a 2 s .c o m public static int getFirstDayOfWeek(Context context) { int startDay = Calendar.getInstance().getFirstDayOfWeek(); if (startDay == Calendar.SATURDAY) { return Time.SATURDAY; } else if (startDay == Calendar.MONDAY) { return Time.MONDAY; } else { return Time.SUNDAY; } }
From source file:com.mirth.connect.donkey.model.channel.PollConnectorPropertiesAdvanced.java
public PollConnectorPropertiesAdvanced() { weekly = true;// ww w . j a va2 s .com inactiveDays = new boolean[8]; inactiveDays[Calendar.SUNDAY] = false; // true means to exclude inactiveDays[Calendar.MONDAY] = false; inactiveDays[Calendar.TUESDAY] = false; inactiveDays[Calendar.WEDNESDAY] = false; inactiveDays[Calendar.THURSDAY] = false; inactiveDays[Calendar.FRIDAY] = false; inactiveDays[Calendar.SATURDAY] = false; dayOfMonth = 1; allDay = true; startingHour = 8; startingMinute = endingMinute = 0; endingHour = 17; }
From source file:TimeUtil.java
public static String dayStringFormat(long msecs) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(new Date(msecs)); int dow = cal.get(Calendar.DAY_OF_WEEK); switch (dow) { case Calendar.MONDAY: return "Monday"; case Calendar.TUESDAY: return "Tuesday"; case Calendar.WEDNESDAY: return "Wednesday"; case Calendar.THURSDAY: return "Thursday"; case Calendar.FRIDAY: return "Friday"; case Calendar.SATURDAY: return "Saturday"; case Calendar.SUNDAY: return "Sunday"; }/*w ww . j av a 2 s. c o m*/ return "Unknown"; }
From source file:org.exoplatform.addons.sdpDemo.populator.services.Utils.java
/** * Gets the day as int./*from w w w . j av a 2 s . c o m*/ * * @param day the day * @return the day as int */ public static int getDayAsInt(String day) { if ("monday".equals(day)) return Calendar.MONDAY; else if ("tuesday".equals(day)) return Calendar.TUESDAY; else if ("wednesday".equals(day)) return Calendar.WEDNESDAY; else if ("thursday".equals(day)) return Calendar.THURSDAY; else if ("friday".equals(day)) return Calendar.FRIDAY; else if ("saturday".equals(day)) return Calendar.SATURDAY; else if ("sunday".equals(day)) return Calendar.SUNDAY; return Calendar.MONDAY; }
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"))); }/*from ww w . ja v a 2s .c om*/ 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: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 ww . 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: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);//from w w w.java 2s . 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: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"))); }// w ww . j a v a2 s. c om 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:com.binary_machinery.avalonschedule.view.schedule.SchedulePageFragment.java
@Nullable @Override/*from w ww . ja va 2 s .co 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; }