Example usage for java.util Calendar THURSDAY

List of usage examples for java.util Calendar THURSDAY

Introduction

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

Prototype

int THURSDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Thursday.

Usage

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  w  w.j ava  2  s.  c om
 * @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: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  ww.j  a  v  a 2  s  . c o  m

    return startTime;
}

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

/**
 * Create Category Dataset based on Weight , date start and resource
 * @param start/*ww w.  j a v  a  2 s  .  co m*/
 * @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:se.technipelago.weather.chart.Generator.java

public Map<String, Object> getWeatherData() {
    Map<String, Object> map = new HashMap<String, Object>();

    // Put archived data into the map.
    setArchivedData(map);//  ww  w.  jav  a  2s .  com

    // Put current data into the map.
    setCurrentData(map);

    // Daily high/low values.
    //
    Calendar cal = Calendar.getInstance();
    cal.setTime((Date) map.get("timestamp"));
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    cal.add(Calendar.DAY_OF_MONTH, -6);
    Date day7 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, 6);
    Date day0 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, 1);
    cal.add(Calendar.MILLISECOND, -1);
    Date day1 = cal.getTime();
    // High values.
    setHiLowData(day0, day1, "temp_out", true, map, "dailyHighTemp");
    setHiLowData(day0, day1, "hum_out", true, map, "dailyHighHumidity");
    setHiLowData(day0, day1, "wind_high", true, map, "dailyHighWind");
    // Low values.
    setHiLowData(day0, day1, "temp_out", false, map, "dailyLowTemp");
    setHiLowData(day0, day1, "hum_out", false, map, "dailyLowHumidity");
    setHiLowData(day0, day1, "wind_avg", false, map, "dailyLowWind");

    map.put("rain_today", getValue(day0, day1, "rain", SUM));

    map.put("solar_hours", getSolarHours(new Timespan(day7, day1)));

    cal.set(Calendar.MONTH, Calendar.JUNE);
    cal.set(Calendar.DAY_OF_MONTH, 19);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Date midsummer = cal.getTime();
    cal.setTime(new Date());
    cal.set(Calendar.HOUR_OF_DAY, 23);
    cal.set(Calendar.MINUTE, 59);
    cal.set(Calendar.SECOND, 59);
    cal.set(Calendar.MILLISECOND, 999);
    while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) {
        cal.add(Calendar.DAY_OF_MONTH, -1);
    }
    Date thursday = cal.getTime();
    if (thursday.getTime() > midsummer.getTime()) {
        map.put("solligan", getSolarHours(new Timespan(midsummer, thursday)));
        map.put("solligan_time", thursday);
    } else {
        map.put("solligan", Float.valueOf(0));
    }

    return map;
}

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;
    }//w  w w  . j  a  v a  2s  . c  om

    return endTime;
}

From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java

private int day(String sDay) {
    if (isEmpty(sDay)) {
        return -1;
    }/*w w w .  j av a 2 s. co  m*/
    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;
    }
}

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  av a2s. c  o 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 boolean isActiveDate(Calendar cal) {
    int day = cal.get(Calendar.DAY_OF_WEEK);

    long timeSinceStart = cal.get(Calendar.HOUR_OF_DAY) * 3600000 + cal.get(Calendar.MINUTE) * 60000
            + cal.get(Calendar.SECOND) * 1000;

    if (day == Calendar.SUNDAY) {
        return (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd);
    } else if (day == Calendar.MONDAY) {
        return (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd);
    } else if (day == Calendar.TUESDAY) {
        return (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd);
    } else if (day == Calendar.WEDNESDAY) {
        return (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd);
    } else if (day == Calendar.THURSDAY) {
        return (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd);
    } else if (day == Calendar.FRIDAY) {
        return (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd);
    } else if (day == Calendar.SATURDAY) {
        return (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd);
    } else {/*  ww w . jav  a  2s . co m*/
        return false;
    }
}

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);/*from w ww.  ja va2s  .  c  o  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;

    /*
     *     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:com.jdo.CloudContactUtils.java

public static String getDay() {

    int d = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
    String day = "sun";
    switch (d) {/*  www  .j  a  v  a  2 s .c om*/

    case Calendar.SUNDAY:
        day = "sun";
        break;

    case Calendar.MONDAY:
        day = "mon";
        break;

    case Calendar.TUESDAY:
        day = "tue";
        break;

    case Calendar.WEDNESDAY:
        day = "wed";
        break;

    case Calendar.THURSDAY:
        day = "thu";
        break;

    case Calendar.FRIDAY:
        day = "fri";
        break;

    case Calendar.SATURDAY:
        day = "sat";
        break;
    }

    return day;
}