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.projity.pm.calendar.WorkingCalendar.java
static WorkingCalendar getNightShiftInstance() { if (nightShiftInstance != null) return nightShiftInstance; nightShiftInstance = WorkingCalendar.getStandardBasedInstance(); WorkDay nonWorking = null;/*from ww w . ja va 2 s .co m*/ 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:UserInterface.TMAnalystRole.TMAnaylstWorkAreaJPanel.java
private void generateGraph(Train selectedTrain) { ArrayList<TrainOffered> selectedTrainOfferedListWEEKDAYS = new ArrayList<>(); ArrayList<TrainOffered> selectedTrainOfferedListWEEKENDS = new ArrayList<>(); int days = (int) spnrRecord.getValue(); Date today = new Date(); Date olderThanToday = new Date(); olderThanToday.setTime(today.getTime() + (long) (-days) * 1000 * 60 * 60 * 24); long todayDate = (today.getTime()) / (1000 * 60 * 60 * 24); long olderDate = (olderThanToday.getTime()) / (1000 * 60 * 60 * 24); for (TrainOffered selectedTrainOffered : enterprise.getTrainsOfferedHistory().getTrainsOffered()) { if (selectedTrainOffered.getTrain().equals(selectedTrain)) { long selectedDate = (selectedTrainOffered.getDayOffered().getTime()) / (1000 * 60 * 60 * 24); if (selectedDate >= olderDate && selectedDate <= todayDate) { Calendar date = Calendar.getInstance(); date.setTime(selectedTrainOffered.getDayOffered()); if ((date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) || ((date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY))) { if (!selectedTrainOfferedListWEEKENDS.contains(selectedTrainOffered)) { selectedTrainOfferedListWEEKENDS.add(selectedTrainOffered); }/*w w w. j a v a 2s . co m*/ } else { if (!selectedTrainOfferedListWEEKDAYS.contains(selectedTrainOffered)) { selectedTrainOfferedListWEEKDAYS.add(selectedTrainOffered); } } } } } Map<TimeSlot.TimeSlotRange, Integer> weekendData = new HashMap<TimeSlot.TimeSlotRange, Integer>(); for (TrainOffered selectedTrainOfferedOnWeekend : selectedTrainOfferedListWEEKENDS) { for (TrainStatus rt : selectedTrainOfferedOnWeekend.getRunningTrains()) { if (weekendData.containsKey(rt.getTrainSchedule().getTimeSlot())) { Integer previousValue = weekendData.get(rt.getTrainSchedule().getTimeSlot()); weekendData.put(rt.getTrainSchedule().getTimeSlot(), previousValue + rt.getRunningCapacity()); } else { weekendData.put(rt.getTrainSchedule().getTimeSlot(), rt.getRunningCapacity()); } } } ArrayList<Integer> sortedWeekendData = new ArrayList<>(); if (weekendData.size() > 0) { for (TimeSlot.TimeSlotRange tsr : TimeSlot.TimeSlotRange.values()) { sortedWeekendData.add(weekendData.get(tsr)); } } Map<TimeSlot.TimeSlotRange, Integer> weekdayData = new HashMap<>(); for (TrainOffered selectedTrainOfferedOnWeekDays : selectedTrainOfferedListWEEKDAYS) { for (TrainStatus rt : selectedTrainOfferedOnWeekDays.getRunningTrains()) { if (weekdayData.containsKey(rt.getTrainSchedule().getTimeSlot())) { Integer previousValue = weekdayData.get(rt.getTrainSchedule().getTimeSlot()); weekdayData.put(rt.getTrainSchedule().getTimeSlot(), previousValue + rt.getRunningCapacity()); } else { weekdayData.put(rt.getTrainSchedule().getTimeSlot(), rt.getRunningCapacity()); } } } ArrayList<Integer> sortedWeekDayDataList = new ArrayList<>(); if (weekdayData.size() > 0) { for (TimeSlot.TimeSlotRange tsr : TimeSlot.TimeSlotRange.values()) { sortedWeekDayDataList.add(weekdayData.get(tsr)); } } CategoryDataset dataset; String series1 = "Weekdays"; String series2 = "Weekends"; String series3 = "Maximum Capcity"; DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); for (int i = 0; i < sortedWeekendData.size(); i++) { dataset1.addValue(Math.round(sortedWeekendData.get(i) / selectedTrainOfferedListWEEKENDS.size()), series2, TimeSlot.TimeSlotRange.values()[i].getValue()); } for (int i = 0; i < sortedWeekDayDataList.size(); i++) { // System.out.println("Key = " + entry.getKey().getValue() + ", Value = " + Math.round(entry.getValue()/selectedTrainOfferedListWEEKENDS.size())); dataset1.addValue(Math.round(sortedWeekDayDataList.get(i) / selectedTrainOfferedListWEEKDAYS.size()), series1, TimeSlot.TimeSlotRange.values()[i].getValue()); } for (int i = 0; i < 15; i++) { // System.out.println("Key = " + entry.getKey().getValue() + ", Value = " + Math.round(entry.getValue()/selectedTrainOfferedListWEEKENDS.size())); dataset1.addValue(selectedTrain.getTrainCapacity(), series3, TimeSlot.TimeSlotRange.values()[i].getValue()); } dataset = dataset1; final JFreeChart chart = ChartFactory.createLineChart( "Average Congestion of Train : " + selectedTrain.getTrainName(), // chart title "Time Slot", // domain axis label "Congestion Level", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); ChartFrame chartPanel = new ChartFrame("Line Chart of Train", chart); chartPanel.setSize(this.getWidth(), this.getHeight() + 200); chartPanel.setVisible(true); }
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; }/* w ww .ja v a 2 s . c om*/ return closedTime; }
From source file:com.silverpeas.scheduler.simple.SchedulerJob.java
/** * This method sets the scheduling parameter. The time settings are given by vectors. Each vector * holds a list of Integer objects (currently ordered). Every Integer represents a element of a * timestamp (cron like).//from w w w. jav a 2 s .c o m * @param startMinutes A list of minutes (0-59) * @param startHours A list of hours (0-23) * @param startDaysOfMonth A list of days of a month (1-31) * @param startMonths A list of months (1-12; starts with 1 for January) * @param startDaysOfWeek A list of day of a week (0-6; starts with 0 for Sunday) */ protected synchronized void setSchedulingParameter(List<Integer> startMinutes, List<Integer> startHours, List<Integer> startDaysOfMonth, List<Integer> startMonths, List<Integer> startDaysOfWeek) throws SchedulerException { Enumeration vectorEnumerator; List<Integer> workVector; int workInt; // Check minute values if (startMinutes == null) { startMinutes = new ArrayList<Integer>(); } for (Integer minute : startMinutes) { try { workInt = minute; if ((workInt < 0) || (workInt > 59)) { throw new SchedulerException("SchedulerMethodJob.setParameter: A minute value is out of range"); } } catch (ClassCastException aException) { throw new SchedulerException("SchedulerMethodJob.setParameter: Can't convert a minute value"); } } // Check hour values if (startHours == null) { startHours = new ArrayList<Integer>(); } for (Integer hours : startHours) { try { workInt = hours; if ((workInt < 0) || (workInt > 23)) { throw new SchedulerException("SchedulerMethodJob.setParameter: A hour value is out of range"); } } catch (ClassCastException aException) { throw new SchedulerException("SchedulerMethodJob.setParameter: Can't convert a hour value"); } } // Check day of month values if (startDaysOfMonth == null) { startDaysOfMonth = new ArrayList<Integer>(); } for (Integer days : startDaysOfMonth) { try { workInt = days; if ((workInt < 1) || (workInt > 31)) { throw new SchedulerException( "SchedulerMethodJob.setParameter: A day of month value is out of range"); } } catch (ClassCastException aException) { throw new SchedulerException("SchedulerMethodJob.setParameter: Can't convert a day of month value"); } } // Check month values and normalize them for internal usage if (startMonths == null) { startMonths = new ArrayList<Integer>(); } workVector = new ArrayList<Integer>(); for (Integer month : startMonths) { try { workInt = month; if ((workInt < 1) || (workInt > 12)) { throw new SchedulerException("SchedulerMethodJob.setParameter: A month value is out of range"); } workVector.add(workInt - 1); // Internal: zero based } catch (ClassCastException aException) { throw new SchedulerException("SchedulerMethodJob.setParameter: Can't convert a month value"); } } startMonths = workVector; // Check day of week values if (startDaysOfWeek == null) { startDaysOfWeek = new ArrayList<Integer>(); } workVector = new ArrayList<Integer>(); for (Integer daysOfWeek : startDaysOfWeek) { try { workInt = daysOfWeek; if ((workInt < 0) || (workInt > 6)) { throw new SchedulerException( "SchedulerMethodJob.setParameter: A day of week value is out of range"); } // Conversion not realy necessary, but what if SUN changes the // implementation .... :-)) switch (workInt) { case 0: workVector.add(Calendar.SUNDAY); break; case 1: workVector.add(Calendar.MONDAY); break; case 2: workVector.add(Calendar.TUESDAY); break; case 3: workVector.add(Calendar.WEDNESDAY); break; case 4: workVector.add(Calendar.THURSDAY); break; case 5: workVector.add(Calendar.FRIDAY); break; case 6: workVector.add(Calendar.SATURDAY); break; } } catch (ClassCastException aException) { throw new SchedulerException("SchedulerMethodJob.setParameter: Can't convert a day of week value"); } } startDaysOfWeek = workVector; // Assign the calculated values vMinutes = startMinutes; vHours = startHours; vDaysOfMonth = startDaysOfMonth; vMonths = startMonths; vDaysOfWeek = startDaysOfWeek; // Sort the calculated vectors sortCronVectors(); }
From source file:com.mohamadamin.persianmaterialdatetimepicker.date.MonthView.java
/** * Sets all the parameters for displaying this week. The only required * parameter is the week number. Other parameters have a default value and * will only update if a new value is included, except for focus month, * which will always default to no focus month if no value is passed in. See * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters. * * @param params A map of the new parameters, see * {@link #VIEW_PARAMS_HEIGHT} *//* w w w . j a va 2s . c o m*/ public void setMonthParams(HashMap<String, Integer> params) { if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) { throw new InvalidParameterException("You must specify month and year for this view"); } setTag(params); // We keep the current value for any params not present if (params.containsKey(VIEW_PARAMS_HEIGHT)) { mRowHeight = params.get(VIEW_PARAMS_HEIGHT); if (mRowHeight < MIN_HEIGHT) { mRowHeight = MIN_HEIGHT; } } if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) { mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY); } // Allocate space for caching the day numbers and focus values mMonth = params.get(VIEW_PARAMS_MONTH); mYear = params.get(VIEW_PARAMS_YEAR); // Figure out what day today is //final Time today = new Time(Time.getCurrentTimezone()); //today.setToNow(); final PersianCalendar today = new PersianCalendar(); mHasToday = false; mToday = -1; mPersianCalendar.setPersianDate(mYear, mMonth, 1); mDayOfWeekStart = mPersianCalendar.get(Calendar.DAY_OF_WEEK); if (params.containsKey(VIEW_PARAMS_WEEK_START)) { mWeekStart = params.get(VIEW_PARAMS_WEEK_START); } else { mWeekStart = Calendar.SATURDAY; } mNumCells = Utils.getDaysInMonth(mMonth, mYear); for (int i = 0; i < mNumCells; i++) { final int day = i + 1; if (sameDay(day, today)) { mHasToday = true; mToday = day; } } mNumRows = calculateNumRows(); // Invalidate cached accessibility information. mTouchHelper.invalidateRoot(); }
From source file:com.castis.xylophone.adsmadapter.common.util.InventorySizePolicyGenerator.java
private List<String> getTimeExternalID(InventoryBoxDayCode dayCode, List<String> timeValueList) { List<String> externalIDList = new ArrayList<String>(); switch (dayCode) { case WEEKDAY: for (String timeValue : timeValueList) { timeValue = timeValue.length() < 2 ? "0" + timeValue : timeValue; externalIDList.add("W.*.W" + Calendar.MONDAY + ".H" + timeValue); externalIDList.add("W.*.W" + Calendar.TUESDAY + ".H" + timeValue); externalIDList.add("W.*.W" + Calendar.WEDNESDAY + ".H" + timeValue); externalIDList.add("W.*.W" + Calendar.THURSDAY + ".H" + timeValue); externalIDList.add("W.*.W" + Calendar.FRIDAY + ".H" + timeValue); }/*from ww w. j a v a 2s . c o m*/ break; case WEEKEND: for (String timeValue : timeValueList) { timeValue = timeValue.length() < 2 ? "0" + timeValue : timeValue; externalIDList.add("W.*.W" + Calendar.SUNDAY + ".H" + timeValue); externalIDList.add("W.*.W" + Calendar.SATURDAY + ".H" + timeValue); } break; } return externalIDList; }
From source file:org.sakaiproject.tool.summarycalendar.ui.CalendarBean.java
private CalendarEventVector getEventsFromSchedule() { if (calendarEventVector == null) { Calendar firstDay;/*from w w w .j a v a 2 s . c o m*/ 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:com.mohamadamin.persianmaterialdatetimepicker.multidate.MonthView.java
/** * Sets all the parameters for displaying this week. The only required * parameter is the week number. Other parameters have a default value and * will only update if a new value is included, except for focus month, * which will always default to no focus month if no value is passed in. See * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters. * * @param params A map of the new parameters, see * {@link #VIEW_PARAMS_HEIGHT} *///from w ww . j a v a2s .com public void setMonthParams(HashMap<String, Object> params) { if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) { throw new InvalidParameterException("You must specify month and year for this view"); } setTag(params); // We keep the current value for any params not present if (params.containsKey(VIEW_PARAMS_HEIGHT)) { mRowHeight = (int) params.get(VIEW_PARAMS_HEIGHT); if (mRowHeight < MIN_HEIGHT) { mRowHeight = MIN_HEIGHT; } } if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) { mSelectedDay = (int) params.get(VIEW_PARAMS_SELECTED_DAY); } if (params.containsKey(VIEW_PARAMS_SELECTED_DAYS)) { mSelectedDays = (ArrayList<Integer>) params.get(VIEW_PARAMS_SELECTED_DAYS); } // Allocate space for caching the day numbers and focus values mMonth = (int) params.get(VIEW_PARAMS_MONTH); mYear = (int) params.get(VIEW_PARAMS_YEAR); // Figure out what day today is //final Time today = new Time(Time.getCurrentTimezone()); //today.setToNow(); final PersianCalendar today = new PersianCalendar(); mHasToday = false; mToday = -1; mPersianCalendar.setPersianDate(mYear, mMonth, 1); mDayOfWeekStart = mPersianCalendar.get(Calendar.DAY_OF_WEEK); if (params.containsKey(VIEW_PARAMS_WEEK_START)) { mWeekStart = (int) params.get(VIEW_PARAMS_WEEK_START); } else { mWeekStart = Calendar.SATURDAY; } mNumCells = Utils.getDaysInMonth(mMonth, mYear); for (int i = 0; i < mNumCells; i++) { final int day = i + 1; if (sameDay(day, today)) { mHasToday = true; mToday = day; } } mNumRows = calculateNumRows(); // Invalidate cached accessibility information. mTouchHelper.invalidateRoot(); }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
private long getStartTime(int day) { long startTime = 0; if (day == Calendar.SUNDAY) { startTime = this.sundayStart; } else if (day == Calendar.MONDAY) { startTime = this.mondayStart; } else if (day == Calendar.TUESDAY) { startTime = this.tuesdayStart; } else if (day == Calendar.WEDNESDAY) { startTime = this.wednesdayStart; } else if (day == Calendar.THURSDAY) { startTime = this.thursdayStart; } else if (day == Calendar.FRIDAY) { startTime = this.fridayStart; } else if (day == Calendar.SATURDAY) { startTime = this.saturdayStart; }/*from www.ja v a2 s . c o m*/ return startTime; }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
private long getEndTime(int day) { long endTime = 0; if (day == Calendar.SUNDAY) { endTime = this.sundayEnd; } else if (day == Calendar.MONDAY) { endTime = this.mondayEnd; } else if (day == Calendar.TUESDAY) { endTime = this.tuesdayEnd; } else if (day == Calendar.WEDNESDAY) { endTime = this.wednesdayEnd; } else if (day == Calendar.THURSDAY) { endTime = this.thursdayEnd; } else if (day == Calendar.FRIDAY) { endTime = this.fridayEnd; } else if (day == Calendar.SATURDAY) { endTime = this.saturdayEnd; }//from ww w.ja v a2s . c o m return endTime; }