Example usage for java.util Calendar FRIDAY

List of usage examples for java.util Calendar FRIDAY

Introduction

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

Prototype

int FRIDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Friday.

Usage

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://  w ww .  j a  va2 s.c  om
        return "sabado";
    }
}

From source file:voldemort.scheduled.DataCleanupJobTest.java

public void testCleanupStartTime() {
    // Make sure the default is always the next day.
    GregorianCalendar cal = new GregorianCalendar();
    assertEquals("Default is not tomorrow", Utils.getDayOfTheWeekFromNow(1),
            (cal.get(Calendar.DAY_OF_WEEK) + 1) % 7);

    // When starting the server any day in the week from SUN to FRI and
    // targeting a saturday, should always start on the next saturday
    GregorianCalendar expectedStart = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 29, 0, 0, 0);
    Random rand = new Random();
    for (int day = Calendar.SUNDAY; day <= Calendar.FRIDAY; day++) {
        GregorianCalendar serverStartTime = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 22 + day,
                rand.nextInt(24), rand.nextInt(60), rand.nextInt(60));
        GregorianCalendar computedStart = Utils.getCalendarForNextRun(serverStartTime, Calendar.SATURDAY, 0);
        assertEquals(//from w  w w . ja v  a  2s.c  o  m
                "Expected :" + expectedStart.getTimeInMillis() + " Computed: "
                        + computedStart.getTimeInMillis(),
                expectedStart.getTimeInMillis(), computedStart.getTimeInMillis());
    }

    // Targeting saturday, 00:00 and starting on a friday 23:59:59 should
    // start the next saturday
    GregorianCalendar serverStartTime = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 28, 23, 59, 59);
    GregorianCalendar computedStart = Utils.getCalendarForNextRun(serverStartTime, Calendar.SATURDAY, 0);
    assertEquals(
            "Expected :" + expectedStart.getTimeInMillis() + " Computed: " + computedStart.getTimeInMillis(),
            expectedStart.getTimeInMillis(), computedStart.getTimeInMillis());

    // If we start past the start hour on the target day, it should start
    // the next week
    serverStartTime = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 29, 1, 0, 1);
    computedStart = Utils.getCalendarForNextRun(serverStartTime, Calendar.SATURDAY, 0);
    assertEquals(Calendar.SATURDAY, computedStart.get(Calendar.DAY_OF_WEEK));
    assertEquals(serverStartTime.get(Calendar.DAY_OF_YEAR) + 7, computedStart.get(Calendar.DAY_OF_YEAR));
}

From source file:paarmann.physikprofil.MainActivity.java

public void onBtnAfterTomorrowClick(View view) {
    Calendar cal = Calendar.getInstance();
    int offset;//  w w  w.j  a  v  a  2  s . com
    if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY
            || cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {
        offset = 4;
    } else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
        offset = 3;
    } else {
        offset = 2;
    }
    cal.add(Calendar.DAY_OF_MONTH, offset);
    Intent details = new Intent(this, HomeworkDetailActivity.class);
    String date = cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH) + 1) + "-"
            + cal.get(Calendar.DAY_OF_MONTH);
    details.putExtra(HomeworkDetailActivity.EXTRA_DATE, date);
    startActivity(details);
}

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  av  a  2 s. c o  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: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.  ja  v  a  2 s. co m
        return 0;
    }
}

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

/**
 * .//from  w  ww  .  j a va2  s  . com
 *
 * @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:org.eevolution.form.CRP.java

/**
 * Create Category Dataset based on date start and resource
 * @param start/*w ww. j  av  a 2  s  . co m*/
 * @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:com.ubundude.timesheet.ReportFragment.java

/**
 * Method to get the Calendar day of week Integer
 * //w w  w .j a  v a  2s  . c om
 * @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;
}