Example usage for java.util Calendar TUESDAY

List of usage examples for java.util Calendar TUESDAY

Introduction

In this page you can find the example usage for java.util Calendar TUESDAY.

Prototype

int TUESDAY

To view the source code for java.util Calendar TUESDAY.

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Tuesday.

Usage

From source file:com.provision.alarmemi.paper.fragments.SetAlarmFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    mActivity.setOnLifeCycleChangeListener(this);

    isChanged = isCloud = false;/*from   w w w .j a va2  s.  c o  m*/
    // Override the default content view.
    root = (ViewGroup) super.onCreateView(inflater, container, bundle);
    final ImageView moreAlarm = (ImageView) root.findViewById(R.id.more_alarm);
    FragmentChangeActivity.moreAlarm = moreAlarm;
    moreAlarm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (menu.isMenuShowing()) {
                menu.showContent();
            } else {
                menu.showMenu(true);
            }
        }
    });
    // Make the entire view selected when focused.
    moreAlarm.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            v.setSelected(hasFocus);
        }
    });

    addPreferencesFromResource(R.xml.alarm_prefs);
    myUUID = SplashActivity.myUUID;

    // Get each preference so we can retrieve the value later.
    mLabel = findPreference("label");
    mLabel.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showEditTextPreference(mLabel.getKey(), mLabel.getTitle(), mLabelText);
            return true;
        }
    });

    Preference.OnPreferenceChangeListener preferceChangedListener = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference p, Object newValue) {
            isChanged = true;
            return true;
        }
    };

    mEnabledPref = (CheckBoxPreference) findPreference("enabled");
    mEnabledPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (!isCloud) {
                isChanged = true;
                if ((Boolean) newValue)
                    showCategory();
                else
                    hideCategory();
                return true;
            }
            if ((Boolean) newValue) {
                try {
                    tempjson = new JSONArray("[]");
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                selectedDevice = "";
                for (int i = 0; i < json.length(); i++) {
                    if (UIDitems[i].toString().equals(myUUID))
                        checkedItems[i] = true;
                    if (checkedItems[i]) {
                        Map<String, String> map = new HashMap<String, String>();
                        map.put("name", URLDecoder.decode(items[i].toString()));
                        map.put("uid", UIDitems[i].toString());
                        tempjson.put(map);
                        selectedDevice += items[i] + ", ";
                    }
                }
                if (!selectedDevice.equals(""))
                    selectedDevice = selectedDevice.substring(0, selectedDevice.length() - 2);
            } else {
                try {
                    tempjson = new JSONArray("[]");
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                selectedDevice = "";
                for (int i = 0; i < json.length(); i++) {
                    if (UIDitems[i].toString().equals(myUUID))
                        checkedItems[i] = false;
                    if (checkedItems[i]) {
                        Map<String, String> map = new HashMap<String, String>();
                        map.put("name", URLDecoder.decode(items[i].toString()));
                        map.put("uid", UIDitems[i].toString());
                        tempjson.put(map);
                        selectedDevice += items[i] + ", ";
                    }
                }
                if (!selectedDevice.equals(""))
                    selectedDevice = selectedDevice.substring(0, selectedDevice.length() - 2);
            }
            mForest.setSummary(selectedDevice);
            isChanged = true;
            return true;
        }
    });
    mTimePref = findPreference("time");
    mVibratePref = (CheckBoxPreference) findPreference("vibrate");
    mVibratePref.setOnPreferenceChangeListener(preferceChangedListener);
    mRepeatPref = findPreference("setRepeat");
    mRepeatPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] values = new String[] {
                    DateUtils.getDayOfWeekString(Calendar.MONDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.TUESDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.WEDNESDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.THURSDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.FRIDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.SATURDAY, DateUtils.LENGTH_LONG),
                    DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_LONG) };
            Intent intent = new Intent(mActivity, RepeatListPreference.class);
            intent.putExtra("key", mRepeatPref.getKey());
            intent.putExtra("title", mRepeatPref.getTitle());
            intent.putExtra("lists", values);
            intent.putExtra("multi", true);
            startActivity(intent);
            return true;
        }
    });
    mForestName = findPreference("forest_name");
    mForest = findPreference("forest");
    mColorPref = (AmbilWarnaPreference) findPreference("color");
    prefs = mActivity.getSharedPreferences("forest", mActivity.MODE_PRIVATE);

    Intent i = mActivity.setAlarmGetIntent;
    mId = i.getIntExtra(Alarms.ALARM_ID, -1);

    alarm = null;
    if (mId == -1) {
        // No alarm id means create a new alarm.
        alarm = new Alarm();
        isChanged = true;
    } else {
        // * load alarm details from database
        alarm = Alarms.getAlarm(mActivity.getContentResolver(), mId);
        // Bad alarm, bail to avoid a NPE.
        if (alarm == null) {
            finish();
            return root;
        }
        isCloud = wasCloud = alarm.cloudEnabled;
    }
    mOriginalAlarm = alarm;

    if (wasCloud) {
        try {
            Log.e("url", " : " + alarm.cloudName);
            json = new JSONArray(prefs.getString(alarm.cloudName + "_registeredDevice", ""));
            String cloud_uid = alarm.cloudUID;
            if (cloud_uid.equals(""))
                cloud_uid = "[]";
            Log.e("url", cloud_uid);
            tempjson = new JSONArray(cloud_uid);
            items = new String[json.length()];
            UIDitems = new CharSequence[json.length()];
            checkedItems = new boolean[json.length()];
            for (int j = 0; j < json.length(); j++) {
                JSONObject jsonObj = json.getJSONObject(j);
                items[j] = jsonObj.getString("name");
                UIDitems[j] = jsonObj.getString("uid");
                checkedItems[j] = alarm.cloudUID.contains(jsonObj.getString("uid"));
            }
        } catch (Exception e) {
            Log.e("url", e.toString());
        }
        selectedDevice = alarm.cloudDevices;
        mForestName.setEnabled(false);
    } else {
        if (prefs.getString("name", "").length() > 0) {
            names = prefs.getString("name", "").substring(1).split("\\|");
            nameCheckedIndex = -1;
        } else
            mForestName.setEnabled(false);
        mForest.setEnabled(false);
    }
    memi_count = alarm.memiCount;
    snooze_strength = alarm.snoozeStrength;
    snooze_count = alarm.snoozeCount;

    updatePrefs(mOriginalAlarm);

    mTimePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {
            showTimePicker();
            return false;
        }

    });

    mForestName.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showListPreference(mForestName.getKey(), mForestName.getTitle(), names,
                    String.valueOf(nameCheckedIndex), false);
            return true;
        }
    });

    mForest.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            showListPreference(mForest.getKey(), mForest.getTitle(), items, booleanArrayToString(checkedItems),
                    true);
            return true;
        }
    });
    mColorPref.setOnPreferenceChangeListener(preferceChangedListener);

    // We have to do this to get the save/cancel buttons to highlight on
    // their own.
    ((ListView) root.findViewById(android.R.id.list)).setItemsCanFocus(true);

    // Attach actions to each button.
    View.OnClickListener back_click = new View.OnClickListener() {
        public void onClick(View v) {
            DontSaveDialog(false, null, false);
        }
    };
    ImageView b = (ImageView) root.findViewById(R.id.back);
    b.setOnClickListener(back_click);

    b = (ImageView) root.findViewById(R.id.logo);
    b.setOnClickListener(back_click);

    b = (ImageView) root.findViewById(R.id.alarm_save);
    b.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            saveAlarm();
        }
    });
    b = (ImageView) root.findViewById(R.id.alarm_delete);
    if (mId == -1) {
        b.setEnabled(false);
    } else {
        b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                deleteAlarm();
            }
        });
    }

    // The last thing we do is pop the time picker if this is a new alarm.
    if (mId == -1) {
        // Assume the user hit cancel
        mTimePickerCancelled = true;
        showTimePicker();
    }

    if (!isCloud && !alarm.enabled)
        hideCategory();

    FragmentChangeActivity.OnNotifyArrived.sendEmptyMessage(0);
    return root;
}

From source file:Time.java

/**
 * Testing this class./*from   ww  w. jav  a2 s.com*/
 * 
 * @param args
 *          Not used.
 */
public static void main(String[] args) {
    // This proves that there are 912 days between the two major
    // terrorist attacks, not 911 as is common knowledge.
    Day september11 = new Day(2001, Calendar.SEPTEMBER, 11);
    Day march11 = new Day(2004, Calendar.MARCH, 11);
    System.out.println(september11.daysBetween(march11));

    // This proves that Kennedy was president for 1037 days,
    // not 1000 as is the popular belief nor 1036 which is the
    // bluffers reply. Nerds knows when to add one...
    Day precidency = new Day(1961, Calendar.JANUARY, 20);
    Day assasination = new Day(1963, Calendar.NOVEMBER, 22);
    System.out.println(precidency.daysBetween(assasination) + 1);

    // Niel Armstrong walked the moon on a Sunday
    Day nielOnMoon = new Day(1969, Calendar.JULY, 20);
    System.out.println(nielOnMoon.getDayNumberOfWeek());

    // Find last tuesdays for 2005
    for (int i = 0; i < 12; i++) {
        Day tuesday = Day.getLastOfMonth(Calendar.TUESDAY, i, 2005);
        System.out.println(tuesday);
    }
}

From source file:com.projity.pm.calendar.WorkingCalendar.java

static WorkingCalendar getNightShiftInstance() {
    if (nightShiftInstance != null)
        return nightShiftInstance;
    nightShiftInstance = WorkingCalendar.getStandardBasedInstance();
    WorkDay nonWorking = null;//ww  w .ja  v a2  s  . com
    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:org.kuali.student.r2.core.scheduling.service.impl.TestSchedulingServiceImpl.java

@Test
public void testgetTimeSlot() throws Exception {
    // test get by id
    for (int i = 1; i <= 16; i++) {
        int tsId = 100 + i;
        TimeSlot ts = schedulingService.getTimeSlot("ts" + tsId, contextInfo);
        assertNotNull(ts);//ww  w .j  a v a2  s  .  c o  m
        assertEquals("ts" + tsId, ts.getId());
    }

    // test specific records - 2
    TimeSlot ts = schedulingService.getTimeSlot("ts102", contextInfo);
    List<Integer> dow = ts.getWeekdays();
    // should contain Monday, Wednesday, Friday
    assertTrue(dow.contains(Calendar.MONDAY));
    assertTrue(dow.contains(Calendar.WEDNESDAY));
    assertTrue(dow.contains(Calendar.FRIDAY));
    // should not contain Tuesday or Thursday
    assertFalse(dow.contains(Calendar.TUESDAY));
    assertFalse(dow.contains(Calendar.THURSDAY));

    assertEquals(ts.getStartTime(), TOD_8_AM);
    assertEquals(ts.getEndTime(), TOD_9_10_AM);

    // test specific records - 3
    ts = schedulingService.getTimeSlot("ts103", contextInfo);
    dow = ts.getWeekdays();
    // should not contain Monday, Wednesday, Friday
    assertFalse(dow.contains(Calendar.MONDAY));
    assertFalse(dow.contains(Calendar.WEDNESDAY));
    assertFalse(dow.contains(Calendar.FRIDAY));
    // should contain Tuesday or Thursday
    assertTrue(dow.contains(Calendar.TUESDAY));
    assertTrue(dow.contains(Calendar.THURSDAY));
    assertEquals(ts.getStartTime(), TOD_8_AM);
    assertEquals(ts.getEndTime(), TOD_8_50_AM);

    // test specific records - 10
    ts = schedulingService.getTimeSlot("ts110", contextInfo);
    dow = ts.getWeekdays();
    // should contain Monday, Wednesday, Friday
    assertTrue(dow.contains(Calendar.MONDAY));
    assertTrue(dow.contains(Calendar.WEDNESDAY));
    assertTrue(dow.contains(Calendar.FRIDAY));
    // should not contain Tuesday or Thursday
    assertFalse(dow.contains(Calendar.TUESDAY));
    assertFalse(dow.contains(Calendar.THURSDAY));
    assertEquals(ts.getStartTime(), TOD_1_PM);
    assertEquals(ts.getEndTime(), TOD_2_10_PM);
}

From source file:org.eevolution.form.CRP.java

/**
 * Create Category Dataset based on Weight , date start and resource
 * @param start//w w  w  .  java2s .  com
 * @param resource
 * @return CategoryDataset
 */
protected CategoryDataset createWeightDataset(Timestamp start, MResource rosource) {

    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);
    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 = MResourceType.get(Env.getCtx(), rosource.getS_ResourceType_ID());

    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 PP_Order mo WHERE AD_Client_ID=?",
            rosource.getAD_Client_ID());
    double dailyCapacity = rosource.getDailyCapacity().doubleValue();
    double utilization = rosource.getPercentUtilization().doubleValue();
    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 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;
    }//from   w w  w . j av  a  2s . com

    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).//  w ww  .  java  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.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  w ww. j  a va 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.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  w w  w  . java  2s. com*/

    return startTime;
}

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);/*from w w w. j  a  v  a  2 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;
    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;
}