Example usage for java.util Calendar WEDNESDAY

List of usage examples for java.util Calendar WEDNESDAY

Introduction

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

Prototype

int WEDNESDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Wednesday.

Usage

From source file:de.tor.tribes.ui.components.DatePicker.java

/**
 * remaps the days of week of gregorian Calendar to internal values
 *///from  w  w w . ja v a  2s.c om
private int mapDayOfWeek(int cal) {
    switch (cal) {
    case Calendar.MONDAY:
        return 1;
    case Calendar.TUESDAY:
        return 2;
    case Calendar.WEDNESDAY:
        return 3;
    case Calendar.THURSDAY:
        return 4;
    case Calendar.FRIDAY:
        return 5;
    case Calendar.SATURDAY:
        return 6;
    case Calendar.SUNDAY:
        return 7;
    default:
        return 1; //should never happen
    }
}

From source file:org.davidmendoza.esu.service.impl.InicioServiceImpl.java

private String obtieneDia(int dia) {
    switch (dia) {
    case Calendar.SUNDAY:
        return "domingo";
    case Calendar.MONDAY:
        return "lunes";
    case Calendar.TUESDAY:
        return "martes";
    case Calendar.WEDNESDAY:
        return "miercoles";
    case Calendar.THURSDAY:
        return "jueves";
    case Calendar.FRIDAY:
        return "viernes";
    default:/*from w w w.j a  v  a  2s. c  o m*/
        return "sabado";
    }
}

From source file:org.davidmendoza.esu.service.impl.InicioServiceImpl.java

private Integer obtieneDia(String dia) {
    switch (dia) {
    case "domingo":
        return Calendar.SUNDAY;
    case "lunes":
        return Calendar.MONDAY;
    case "martes":
        return Calendar.TUESDAY;
    case "miercoles":
        return Calendar.WEDNESDAY;
    case "jueves":
        return Calendar.THURSDAY;
    case "viernes":
        return Calendar.FRIDAY;
    default:/* w w  w .  j ava 2s. co m*/
        return Calendar.SATURDAY;
    }
}

From source file:com.autentia.jsf.component.ocupation.HtmlOcupationCalendarRenderer.java

private static String[] mapShortWeekdays(DateFormatSymbols symbols) {
    String[] weekdays = new String[7];

    String[] localeWeekdays = symbols.getShortWeekdays();

    weekdays[0] = localeWeekdays[Calendar.MONDAY];
    weekdays[1] = localeWeekdays[Calendar.TUESDAY];
    weekdays[2] = localeWeekdays[Calendar.WEDNESDAY];
    weekdays[3] = localeWeekdays[Calendar.THURSDAY];
    weekdays[4] = localeWeekdays[Calendar.FRIDAY];
    weekdays[5] = localeWeekdays[Calendar.SATURDAY];
    weekdays[6] = localeWeekdays[Calendar.SUNDAY];

    return weekdays;
}

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

/**
 * Create Category Dataset based on date start and resource
 * @param start/*from  w w  w  .  j a  v  a2 s . c om*/
 * @param resource
 * @return CategoryDataset
 */
protected CategoryDataset createDataset(Timestamp start, MResource resource) {
    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);

    Timestamp date = start;
    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    String nameload = Msg.translate(Env.getCtx(), "Load");
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    MResourceType t = MResourceType.get(Env.getCtx(), resource.getS_ResourceType_ID());
    int days = 1;
    long hours = t.getTimeSlotHours();

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    //      Long Hours = new Long(hours);                            
    int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ",
            resource.getS_Resource_ID());
    MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID);
    if (!uom.isHour()) {
        return dataset;
    }
    long summary = 0;

    while (days < 32) {
        String day = new String(new Integer(date.getDate()).toString());
        long HoursLoad = getLoad(resource, date).longValue();
        Long Hours = new Long(hours);

        switch (gc1.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            days++;
            if (t.isOnSunday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.MONDAY:
            days++;
            if (t.isOnMonday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.TUESDAY:
            days++;
            if (t.isOnTuesday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.WEDNESDAY:
            days++;
            if (t.isOnWednesday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.THURSDAY:
            days++;
            if (t.isOnThursday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.FRIDAY:
            days++;
            if (t.isOnFriday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {

                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.SATURDAY:
            days++;
            if (t.isOnSaturday()) {
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(HoursLoad, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (HoursLoad);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        }

    }
    return dataset;
}

From source file:it.dbCleaner.PurgeTest.java

/**
 * SONAR-7175/*from   w  w w.  ja v  a2 s .co m*/
 */
@Test
public void keep_latest_snapshot() {
    // Keep all snapshots from last 4 weeks
    setServerProperty(orchestrator, "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek", "4");

    Date oneWeekAgo = addDays(new Date(), -7);

    // Execute an analysis wednesday last week
    Calendar lastWednesday = Calendar.getInstance();
    lastWednesday.setTime(oneWeekAgo);
    lastWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
    String lastWednesdayFormatted = formatDate(lastWednesday.getTime());
    runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", lastWednesdayFormatted);

    // Execute an analysis thursday last week
    Calendar lastThursday = Calendar.getInstance();
    lastThursday.setTime(oneWeekAgo);
    lastThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
    String lastThursdayFormatted = formatDate(lastThursday.getTime());
    runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", lastThursdayFormatted);

    // Now only keep 1 snapshot per week
    setServerProperty(orchestrator, "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek", "0");

    // Execute an analysis today to execute the purge of previous weeks snapshots
    runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH);

    // Check that only analysis from last thursday is kept (as it's the last one from previous week)
    WsMeasures.SearchHistoryResponse response = newAdminWsClient(orchestrator).measures()
            .searchHistory(SearchHistoryRequest.builder().setComponent(PROJECT_KEY)
                    .setMetrics(singletonList("ncloc")).build());
    assertThat(response.getMeasuresCount()).isEqualTo(1);
    assertThat(response.getMeasuresList().get(0).getHistoryList()).extracting(HistoryValue::getDate)
            .doesNotContain(lastWednesdayFormatted, lastThursdayFormatted);
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.renderers.ExamsMapContentRenderer.java

private boolean onValidWeekDay(InfoExam infoExam) {
    int curricularYear = infoExam.getInfoExecutionCourse().getCurricularYear().intValue();
    int weekDay = infoExam.getDay().get(Calendar.DAY_OF_WEEK);

    return ((curricularYear == 1 || curricularYear == 3 || curricularYear == 5)
            && (weekDay == Calendar.MONDAY || weekDay == Calendar.WEDNESDAY || weekDay == Calendar.FRIDAY))
            || ((curricularYear == 2 || curricularYear == 4) && (weekDay == Calendar.TUESDAY
                    || weekDay == Calendar.THURSDAY || weekDay == Calendar.SATURDAY));
}

From source file:com.autentia.jsf.component.ocupation.HtmlOcupationCalendarRenderer.java

private int mapCalendarDayToCommonDay(int day) {
    switch (day) {
    case Calendar.TUESDAY:
        return 1;
    case Calendar.WEDNESDAY:
        return 2;
    case Calendar.THURSDAY:
        return 3;
    case Calendar.FRIDAY:
        return 4;
    case Calendar.SATURDAY:
        return 5;
    case Calendar.SUNDAY:
        return 6;
    default://  www . j  a v a 2  s.  com
        return 0;
    }
}

From source file:cn.mypandora.util.MyDateUtils.java

/**
 * .//from w  ww.ja v a2 s  .  c om
 *
 * @param c
 * @return
 */
public static String getWeekDay(Calendar c) {
    if (c == null) {
        return "";
    }
    switch (c.get(Calendar.DAY_OF_WEEK)) {
    case Calendar.MONDAY:
        return "";
    case Calendar.TUESDAY:
        return "";
    case Calendar.WEDNESDAY:
        return "";
    case Calendar.THURSDAY:
        return "";
    case Calendar.FRIDAY:
        return "";
    case Calendar.SATURDAY:
        return "";
    default:
        return "";
    }
}

From source file:com.ubundude.timesheet.ReportFragment.java

/**
 * Method to get the Calendar day of week Integer
 * //from   w  w w  .ja  v a  2  s. c o m
 * @param lFirstDay The day of the from the shared preferences
 * @return DOW The integer for the day of the week
 */
private int getFirstDay(String lFirstDay) {
    int DOW = Calendar.SUNDAY;

    if (lFirstDay == "MONDAY")
        DOW = Calendar.MONDAY;
    else if (lFirstDay == "TUESDAY")
        DOW = Calendar.TUESDAY;
    else if (lFirstDay == "WEDNESDAY")
        DOW = Calendar.WEDNESDAY;
    else if (lFirstDay == "THURSDAY")
        DOW = Calendar.THURSDAY;
    else if (lFirstDay == "FRIDAY")
        DOW = Calendar.FRIDAY;
    else if (lFirstDay == "SATURDAY")
        DOW = Calendar.SATURDAY;

    return DOW;
}