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.l2jfree.gameserver.model.entity.CCHSiege.java
private void setNextSiegeDate() { while (getSiegeDate().getTimeInMillis() < System.currentTimeMillis()) { if (getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && getSiegeDate().get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); // set the next siege day to the next weekend getSiegeDate().add(Calendar.DAY_OF_MONTH, 7); getSiegeDate().set(Calendar.HOUR_OF_DAY, 20); }/* w w w . j a v a 2s . c om*/ _isRegistrationOver = false; // Allow registration for next siege }
From source file:com.evozon.evoportal.my_account.validator.UserAccountValidation.java
private boolean isWeekendDay(Calendar cal) { int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); boolean isSaturday = (dayOfWeek == Calendar.SATURDAY); boolean isSunday = (dayOfWeek == Calendar.SUNDAY); return isSaturday || isSunday; }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for checking whether the target date is Saturday * /*from w w w. ja v a2 s .com*/ * @param tgtDate * @return */ public static boolean isSaturday(Date tgtDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(tgtDate); return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY ? true : false); }
From source file:com.sonyericsson.hudson.plugins.gerrit.trigger.config.Config.java
/** * Adds the WatchTimeExceptionData from the form. * * @param formData the form./* www .j ava2 s . c o m*/ * @return the WatchTimeExceptionData */ private WatchTimeExceptionData addWatchTimeExceptionData(JSONObject formData) { List<Integer> days = new LinkedList<Integer>(); List<TimeSpan> exceptionTimes = new LinkedList<TimeSpan>(); int[] daysAsInt = new int[] {}; if (formData.has("watchdogExceptions")) { JSONObject jsonObject = formData.getJSONObject(("watchdogExceptions")); if (jsonObject.getBoolean(String.valueOf(Calendar.MONDAY))) { days.add(Calendar.MONDAY); } if (jsonObject.getBoolean(String.valueOf(Calendar.TUESDAY))) { days.add(Calendar.TUESDAY); } if (jsonObject.getBoolean(String.valueOf(Calendar.WEDNESDAY))) { days.add(Calendar.WEDNESDAY); } if (jsonObject.getBoolean(String.valueOf(Calendar.THURSDAY))) { days.add(Calendar.THURSDAY); } if (jsonObject.getBoolean(String.valueOf(Calendar.FRIDAY))) { days.add(Calendar.FRIDAY); } if (jsonObject.getBoolean(String.valueOf(Calendar.SATURDAY))) { days.add(Calendar.SATURDAY); } if (jsonObject.getBoolean(String.valueOf(Calendar.SUNDAY))) { days.add(Calendar.SUNDAY); } daysAsInt = Ints.toArray(days); if (jsonObject.has("watchdogExceptionTimes")) { Object obj = jsonObject.get("watchdogExceptionTimes"); if (obj instanceof JSONArray) { for (Object json : (JSONArray) obj) { exceptionTimes.add(TimeSpan.createTimeSpanFromJSONObject((JSONObject) json)); } } else if (obj instanceof JSONObject) { exceptionTimes.add(TimeSpan.createTimeSpanFromJSONObject((JSONObject) obj)); } } } return new WatchTimeExceptionData(daysAsInt, exceptionTimes); }
From source file:com.borax12.materialdaterangepicker.single.date.DatePickerDialog.java
@SuppressWarnings("unused") 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 w w .ja v a 2s .c o m mWeekStart = startOfWeek; if (mDayPickerView != null) { mDayPickerView.onChange(); } }
From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java
private static boolean isValidDayOfWeek(int day) { return day >= Calendar.SUNDAY && day <= Calendar.SATURDAY; }
From source file:org.ejbca.ui.web.admin.certprof.CertProfileBean.java
public void setExpirationRestrictionSaturday(final boolean enabled) throws AuthorizationDeniedException { getCertificateProfile().setExpirationRestrictionWeekday(Calendar.SATURDAY, enabled); }
From source file:com.silverpeas.scheduler.simple.SchedulerJob.java
/** * This method sets the scheduling parameter. It is given by a cron like string (currently ranges * are not allowed). So the string '* 3,21 * 3 0' starts the execution every Sunday in March on * 03:00 and 21:00. The allowed ranges are: minutes (0-59), hours (0-23), days of a month (1-31), * months (1-12; starts with 1 for January), day of a week (0-6; starts with 0 for Sunday). * Currently the parsing of the cron string ist not done by a state machine but by * StringTokenizers so this method is <B>very</B> sensitive for syntax failures! * @param aCronString//from ww w .j a v a2 s . c o m */ protected synchronized void setSchedulingParameter(CronJobTrigger trigger) throws SchedulerException { setTrigger(trigger); String aCronString = trigger.getCronExpression(); StringTokenizer fieldSeparator; StringTokenizer fieldContentSeparator; String workString; int workInt; if (aCronString == null) { throw new SchedulerException("SchedulerShellJob.setCronString: Parameter 'aCronString' is null"); } if (aCronString.contains("-") || aCronString.contains("/")) { throw new SchedulerException( "This scheduler backend doesn't support yet the range and the increment instructions " + "in cron expressions"); } aCronString = aCronString.replaceAll("\\?", "*"); // Reset current values vMinutes = new ArrayList<Integer>(); vHours = new ArrayList<Integer>(); vDaysOfMonth = new ArrayList<Integer>(); vMonths = new ArrayList<Integer>(); vDaysOfWeek = new ArrayList<Integer>(); // This StringTokenizer splits the cron string into time fields fieldSeparator = new StringTokenizer(aCronString); // Get minute values if (fieldSeparator.hasMoreTokens()) { // This StringTokenizer splits each timefield list into single numbers fieldContentSeparator = new StringTokenizer(fieldSeparator.nextToken(), ","); while (fieldContentSeparator.hasMoreTokens()) { workString = fieldContentSeparator.nextToken(); // Check ingnore token if (workString.equals("*")) { vMinutes = new ArrayList<Integer>(); break; } // Check integer value try { workInt = Integer.parseInt(workString); } catch (NumberFormatException aException) { throw new SchedulerException("SchedulerShellJob.setCronString: Can't convert a minute value"); } if ((workInt < 0) || (workInt > 59)) { throw new SchedulerException("SchedulerShellJob.setCronString: A minute value is out of range"); } vMinutes.add(workInt); } } // Get hour values if (fieldSeparator.hasMoreTokens()) { fieldContentSeparator = new StringTokenizer(fieldSeparator.nextToken(), ","); while (fieldContentSeparator.hasMoreTokens()) { workString = fieldContentSeparator.nextToken(); // Check ingnore token if (workString.equals("*")) { vHours = new ArrayList<Integer>(); break; } // Check iteger value try { workInt = Integer.parseInt(workString); } catch (NumberFormatException aException) { throw new SchedulerException("SchedulerShellJob.setCronString: Can't convert a hour value"); } if ((workInt < 0) || (workInt > 23)) { throw new SchedulerException("SchedulerShellJob.setCronString: A hour value is out of range"); } vHours.add(workInt); } } // Get day of month values and normalize them for internal usage if (fieldSeparator.hasMoreTokens()) { fieldContentSeparator = new StringTokenizer(fieldSeparator.nextToken(), ","); while (fieldContentSeparator.hasMoreTokens()) { workString = fieldContentSeparator.nextToken(); // Check ingnore token if (workString.equals("*")) { vDaysOfMonth = new ArrayList<Integer>(); break; } // Check iteger value try { workInt = Integer.parseInt(workString); } catch (NumberFormatException aException) { throw new SchedulerException( "SchedulerShellJob.setCronString: Can't convert a day of month value"); } if ((workInt < 1) || (workInt > 31)) { throw new SchedulerException( "SchedulerShellJob.setCronString: A day of month value is out of range"); } vDaysOfMonth.add(workInt); } } // Get month values if (fieldSeparator.hasMoreTokens()) { fieldContentSeparator = new StringTokenizer(fieldSeparator.nextToken(), ","); while (fieldContentSeparator.hasMoreTokens()) { workString = fieldContentSeparator.nextToken(); // Check ingnore token if (workString.equals("*")) { vMonths = new ArrayList<Integer>(); break; } // Check iteger value try { workInt = Integer.parseInt(workString); } catch (NumberFormatException aException) { throw new SchedulerException("SchedulerShellJob.setCronString: Can't convert a month value"); } if ((workInt < 1) || (workInt > 12)) { throw new SchedulerException("SchedulerShellJob.setCronString: A month value is out of range"); } vMonths.add(workInt - 1); // Internal: zero based } } // Get day of week values if (fieldSeparator.hasMoreTokens()) { fieldContentSeparator = new StringTokenizer(fieldSeparator.nextToken(), ","); while (fieldContentSeparator.hasMoreTokens()) { workString = fieldContentSeparator.nextToken(); // Check ingnore token if (workString.equals("*")) { vDaysOfWeek = new ArrayList<Integer>(); break; } // Check iteger value try { workInt = Integer.parseInt(workString); } catch (NumberFormatException aException) { throw new SchedulerException( "SchedulerShellJob.setCronString: Can't convert a day of week value"); } if ((workInt < 0) || (workInt > 6)) { throw new SchedulerException( "SchedulerShellJob.setCronString: A day of week value is out of range"); } switch (workInt) { case 0: vDaysOfWeek.add(Calendar.SUNDAY); break; case 1: vDaysOfWeek.add(Calendar.MONDAY); break; case 2: vDaysOfWeek.add(Calendar.TUESDAY); break; case 3: vDaysOfWeek.add(Calendar.WEDNESDAY); break; case 4: vDaysOfWeek.add(Calendar.THURSDAY); break; case 5: vDaysOfWeek.add(Calendar.FRIDAY); break; case 6: vDaysOfWeek.add(Calendar.SATURDAY); break; } } } if (fieldSeparator.hasMoreTokens()) { throw new SchedulerException("SchedulerShellJob.setCronString: Too much time fields in cron string"); } if (vDaysOfWeek == null) { throw new SchedulerException("SchedulerShellJob.setCronString: Not enough time fields in cron string"); } // Sort the calculated vectors sortCronVectors(); }
From source file:org.kuali.student.r2.core.scheduling.service.impl.TestSchedulingServiceImpl.java
@Test public void getValidDaysOfWeekByTimeSlotType() throws Exception { List<Integer> valid_days_act_off = schedulingService.getValidDaysOfWeekByTimeSlotType( SchedulingServiceConstants.TIME_SLOT_TYPE_ACTIVITY_OFFERING_STANDARD_FULLTERM_FALL, contextInfo); // should return days Monday through Saturday assertTrue(valid_days_act_off.contains(Calendar.MONDAY)); assertTrue(valid_days_act_off.contains(Calendar.TUESDAY)); assertTrue(valid_days_act_off.contains(Calendar.WEDNESDAY)); assertTrue(valid_days_act_off.contains(Calendar.THURSDAY)); assertTrue(valid_days_act_off.contains(Calendar.FRIDAY)); assertTrue(valid_days_act_off.contains(Calendar.SATURDAY)); assertTrue(valid_days_act_off.contains(Calendar.SUNDAY)); List<Integer> valid_days_final = schedulingService .getValidDaysOfWeekByTimeSlotType(SchedulingServiceConstants.TIME_SLOT_TYPE_EXAM, contextInfo); // should not return any days assertFalse(valid_days_final.contains(Calendar.MONDAY)); assertFalse(valid_days_final.contains(Calendar.TUESDAY)); assertFalse(valid_days_final.contains(Calendar.WEDNESDAY)); assertFalse(valid_days_final.contains(Calendar.THURSDAY)); assertFalse(valid_days_final.contains(Calendar.FRIDAY)); assertFalse(valid_days_final.contains(Calendar.SATURDAY)); assertFalse(valid_days_final.contains(Calendar.SUNDAY)); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void init(Context context) { setFocusable(true);//from www . j av a 2 s . c o m // Allow focus in touch mode so that we can do keyboard shortcuts // even after we've entered touch mode. setFocusableInTouchMode(true); setClickable(true); setOnCreateContextMenuListener(this); mFirstDayOfWeek = Time.MONDAY; mCurrentTime = new Time(DayUtils.getTimeZone(context, mTZUpdater)); long currentTime = System.currentTimeMillis(); mCurrentTime.set(currentTime); mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.gmtoff); mEventTextPaint.setTextSize(EVENT_TEXT_FONT_SIZE); mEventTextPaint.setTextAlign(Align.LEFT); mEventTextPaint.setAntiAlias(true); int gridLineColor = 0xff707070; Paint p = mSelectionPaint; p.setColor(gridLineColor); p.setStyle(Style.FILL); p.setAntiAlias(false); p = mPaint; p.setAntiAlias(true); // Long day names mDayStrsLong = new String[14]; // Allocate space for 2 weeks worth of weekday names so that we can // easily start the week display at any week day. mDayStrs = new String[14]; // Also create an array of 2-letter abbreviations. mDayStrs2Letter = new String[14]; for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) { int index = i - Calendar.SUNDAY; mDayStrsLong[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase(); mDayStrsLong[index + 7] = mDayStrsLong[index]; // e.g. Tue for Tuesday mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM).toUpperCase(); mDayStrs[index + 7] = mDayStrs[index]; // e.g. Tu for Tuesday mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT).toUpperCase(); // If we don't have 2-letter day strings, fall back to 1-letter. if (mDayStrs2Letter[index].equals(mDayStrs[index])) { mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST); } mDayStrs2Letter[index + 7] = mDayStrs2Letter[index]; } // Figure out how much space we need for the 3-letter abbrev names // in the worst case. p.setTextSize(DATE_HEADER_FONT_SIZE); p.setTypeface(mBold); String[] dateStrs = { " 28", " 30" }; mDateStrWidth = computeMaxStringWidth(0, dateStrs, p); Time time = new Time(); time.setJulianDay(mFirstJulianDay); String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false))); mDateStrWidthLong = computeMaxStringWidth(0, new String[] { s }, p); p.setTextSize(DAY_HEADER_FONT_SIZE); mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p); mDateStrWidthLong += computeMaxStringWidth(0, mDayStrsLong, p); p.setTextSize(HOURS_TEXT_SIZE); p.setTypeface(null); handleOnResume(); mAmString = DateUtils.getAMPMString(Calendar.AM).toUpperCase(); mPmString = DateUtils.getAMPMString(Calendar.PM).toUpperCase(); String[] ampm = { mAmString, mPmString }; p.setTextSize(AMPM_TEXT_SIZE); mHoursWidth = Math.max(HOURS_MARGIN, computeMaxStringWidth(mHoursWidth, ampm, p) + HOURS_RIGHT_MARGIN); mHoursWidth = Math.max(MIN_HOURS_WIDTH, mHoursWidth); LayoutInflater inflater; inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); Resources.Theme dialogTheme = getResources().newTheme(); dialogTheme.applyStyle(android.R.style.Theme_Dialog, true); TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); // Catch long clicks for creating a new event mBaseDate = new Time(DayUtils.getTimeZone(context, mTZUpdater)); long millis = System.currentTimeMillis(); mBaseDate.set(millis); mEarliestStartHour = new int[mNumDays]; mHasAllDayEvent = new boolean[mNumDays]; // mLines is the array of points used with Canvas.drawLines() in // drawGridBackground() and drawAllDayEvents(). Its size depends // on the max number of lines that can ever be drawn by any single // drawLines() call in either of those methods. final int maxGridLines = (24 + 1) // max horizontal lines we might draw + (mNumDays + 1); // max vertical lines we might draw mLines = new float[maxGridLines * 4]; }