List of usage examples for java.util Calendar MONDAY
int MONDAY
To view the source code for java.util Calendar MONDAY.
Click Source Link
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 . j a v a2 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 ww w.j a va2s .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.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); }// w w w .j a v a 2 s.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.eevolution.form.VSCRP.java
public CategoryDataset createWeightDataset(Timestamp start, MResource r) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);// ww w .j ava2 s. co m gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namepossiblecapacity = "Possible Capacity"; MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double currentweight = DB.getSQLValue(null, "Select SUM( (mo.qtyordered-mo.qtydelivered)*(Select mp.weight From m_product mp Where mo.m_product_id=mp.m_product_id ) )From mpc_order mo Where ad_client_id=?", r.getAD_Client_ID()); // fjviejo e-evolution machineqty capacidad por el numero de maquinas // double dailyCapacity = DB.getSQLValue(null,"Select dailycapacity From s_resource Where s_resource_id=?",r.getS_Resource_ID()); double dailyCapacity = DB.getSQLValue(null, "Select dailycapacity*MachineQty From s_resource Where s_resource_id=?", r.getS_Resource_ID()); System.out.println("***** Capacidad diaria " + dailyCapacity); // e-evolution end double utilization = DB.getSQLValue(null, "Select percentutillization From s_resource Where s_resource_id=?", r.getS_Resource_ID()); double summary = 0; int day = 0; while (day < 32) { day++; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.MONDAY: if (t.isOnMonday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.TUESDAY: if (t.isOnTuesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.WEDNESDAY: if (t.isOnWednesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.THURSDAY: if (t.isOnThursday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.FRIDAY: if (t.isOnFriday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.SATURDAY: if (t.isOnSaturday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; } dataset.addValue(currentweight, nameload, new Integer(day)); dataset.addValue(summary, namesummary, new Integer(day)); gc1.add(Calendar.DATE, 1); } return dataset; }
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; }/* ww w .ja v a2 s . c om*/ return startTime; }
From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java
/** * Used to set the selected day and week of the sprint in the activity. * @param dayInMillis/*from ww w . j ava 2 s. c o m*/ */ public void setSelectedDay(long dayInMillis) { // Calculate the selected day position in the viewpager mSelectedDay = (int) TimeUnit.DAYS.convert(dayInMillis - mSprintStartDateInMillis, TimeUnit.MILLISECONDS); Calendar selectedDayAsCalendar = Calendar.getInstance(); selectedDayAsCalendar.setFirstDayOfWeek(Calendar.MONDAY); selectedDayAsCalendar.setTimeInMillis(dayInMillis); // Calculate the selected day position as week in the viewpager mSelectedWeek = selectedDayAsCalendar.get(Calendar.WEEK_OF_YEAR) - mStartDate.get(Calendar.WEEK_OF_YEAR); // Take into account change of year. if (mSelectedWeek < 0) { mSelectedWeek = 52 - mStartDate.get(Calendar.WEEK_OF_YEAR) + selectedDayAsCalendar.get(Calendar.WEEK_OF_YEAR); } else { } // Set the day or week depending on orientation. if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mViewPager.setCurrentItem(mSelectedDay); } else if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mViewPager.setCurrentItem(mSelectedWeek); } }
From source file:org.eevolution.form.VCRP.java
public CategoryDataset createWeightDataset(Timestamp start, MResource r) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);// www . j ava2 s .c om gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namepossiblecapacity = "Possible Capacity"; MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double currentweight = DB.getSQLValue(null, "Select SUM( (mo.qtyordered-mo.qtydelivered)*(Select mp.weight From m_product mp Where mo.m_product_id=mp.m_product_id ) )From mpc_order mo Where ad_client_id=?", r.getAD_Client_ID()); // fjviejo e-evolution machineqty capacidad por el numero de maquinas // double dailyCapacity = DB.getSQLValue(null,"Select dailycapacity From s_resource Where s_resource_id=?",r.getS_Resource_ID()); double dailyCapacity = DB.getSQLValue(null, "Select dailycapacity*MachineQty From s_resource Where s_resource_id=?", r.getS_Resource_ID()); System.out.println("***** Capacidad diaria " + dailyCapacity); // e-evolution end double utilization = DB.getSQLValue(null, "Select percentutillization From s_resource Where s_resource_id=?", r.getS_Resource_ID()); double summary = 0; int day = 0; /* * Vit4B Modificado para que tome 28 dias y * * */ while (day < 29) { day++; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.MONDAY: if (t.isOnMonday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.TUESDAY: if (t.isOnTuesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.WEDNESDAY: if (t.isOnWednesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.THURSDAY: if (t.isOnThursday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.FRIDAY: if (t.isOnFriday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.SATURDAY: if (t.isOnSaturday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; } dataset.addValue(currentweight, nameload, new Integer(day)); dataset.addValue(summary, namesummary, new Integer(day)); gc1.add(Calendar.DATE, 1); } return dataset; }
From source file:org.jfree.data.time.WeekTest.java
/** * A test for a problem in constructing a new Week instance. *///from ww w .j av a 2 s . c o m @Test public void testConstructor() { Locale savedLocale = Locale.getDefault(); TimeZone savedZone = TimeZone.getDefault(); Locale.setDefault(new Locale("da", "DK")); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen")); GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); // first day of week is monday assertEquals(Calendar.MONDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); Date t = cal.getTime(); Week w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(34, w.getWeek()); Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("US/Detroit")); cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault()); // first day of week is Sunday assertEquals(Calendar.SUNDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); t = cal.getTime(); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(35, w.getWeek()); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen"), new Locale("da", "DK")); assertEquals(34, w.getWeek()); Locale.setDefault(savedLocale); TimeZone.setDefault(savedZone); }
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 . j av a 2s . co m*/ return endTime; }
From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java
private int day(String sDay) { if (isEmpty(sDay)) { return -1; }/* w ww. j av a 2 s.c om*/ if (sDay.length() < 3) { return -1; } String prefix = sDay.substring(0, 3).toLowerCase(); DAY d = DAY.fromString(prefix); if (d == null) { return -1; } switch (d) { case SUNDAY: return Calendar.SUNDAY; case MONDAY: return Calendar.MONDAY; case TUESDAY: return Calendar.TUESDAY; case WEDNESDAY: return Calendar.WEDNESDAY; case THURSDAY: return Calendar.THURSDAY; case FRIDAY: return Calendar.FRIDAY; case SATURDAY: return Calendar.SATURDAY; default: return -1; } }