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.structr.common.RecurringDateHelper.java

private static String getShortWeekday(final int wd) {

    switch (wd) {

    case Calendar.MONDAY:
        return ShortWeekday.Mo.name();

    case Calendar.TUESDAY:
        return ShortWeekday.Di.name();

    case Calendar.WEDNESDAY:
        return ShortWeekday.Mi.name();

    case Calendar.THURSDAY:
        return ShortWeekday.Do.name();

    case Calendar.FRIDAY:
        return ShortWeekday.Fr.name();

    case Calendar.SATURDAY:
        return ShortWeekday.Sa.name();

    case Calendar.SUNDAY:
        return ShortWeekday.So.name();

    }/*  w w w . j  a v a 2 s  . co  m*/

    return "";

}

From source file:org.kuali.kfs.module.endow.businessobject.lookup.CalculateProcessDateUsingFrequencyCodeService.java

/**
 * Method to calculate the next processing week date based on the frequency type
 * adds the appropriate number of days to the current date
 * @param dayOfWeek//from www .  jav  a  2  s  .co m
 * @return next processing date
 */
protected Date calculateNextWeeklyDate(String dayOfWeekFromFrequencyCode, Date currentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);

    int daysToAdd = 0;
    int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); // today's day of the week
    int maximumDaysInWeek = calendar.getActualMaximum(Calendar.DAY_OF_WEEK);

    if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.MONDAY)) {
        if (dayOfWeek < Calendar.MONDAY)
            daysToAdd = Calendar.MONDAY - dayOfWeek;
        else
            daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.MONDAY;
    } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.TUESDAY)) {
        if (dayOfWeek < Calendar.TUESDAY)
            daysToAdd = Calendar.TUESDAY - dayOfWeek;
        else
            daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.TUESDAY;
    } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.WEDNESDAY)) {
        if (dayOfWeek < Calendar.WEDNESDAY)
            daysToAdd = Calendar.WEDNESDAY - dayOfWeek;
        else
            daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.WEDNESDAY;
    } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.THURSDAY)) {
        if (dayOfWeek < Calendar.THURSDAY)
            daysToAdd = Calendar.THURSDAY - dayOfWeek;
        else
            daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.THURSDAY;
    } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.FRIDAY)) {
        if (dayOfWeek < Calendar.FRIDAY)
            daysToAdd = Calendar.FRIDAY - dayOfWeek;
        else
            daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.FRIDAY;
    }

    calendar.add(Calendar.DAY_OF_MONTH, daysToAdd);

    return new java.sql.Date(calendar.getTimeInMillis());
}

From source file:com.netflix.simianarmy.basic.BasicCalendar.java

/**
 * Load holidays./*  w  w w .j a  va 2s  .  c  o m*/
 *
 * @param year
 *            the year
 */
protected void loadHolidays(int year) {
    holidays.clear();
    // these aren't all strictly holidays, but days when engineers will likely
    // not be in the office to respond to rampaging monkeys

    // new years, or closest work day
    holidays.add(workDayInYear(year, Calendar.JANUARY, 1));

    // 3rd monday == MLK Day
    holidays.add(dayOfYear(year, Calendar.JANUARY, Calendar.MONDAY, 3));

    // 3rd monday == Presidents Day
    holidays.add(dayOfYear(year, Calendar.FEBRUARY, Calendar.MONDAY, 3));

    // last monday == Memorial Day
    holidays.add(dayOfYear(year, Calendar.MAY, Calendar.MONDAY, -1));

    // 4th of July, or closest work day
    holidays.add(workDayInYear(year, Calendar.JULY, 4));

    // first monday == Labor Day
    holidays.add(dayOfYear(year, Calendar.SEPTEMBER, Calendar.MONDAY, 1));

    // second monday == Columbus Day
    holidays.add(dayOfYear(year, Calendar.OCTOBER, Calendar.MONDAY, 2));

    // veterans day, Nov 11th, or closest work day
    holidays.add(workDayInYear(year, Calendar.NOVEMBER, 11));

    // 4th thursday == Thanksgiving
    holidays.add(dayOfYear(year, Calendar.NOVEMBER, Calendar.THURSDAY, 4));

    // 4th friday == "black friday", monkey goes shopping!
    holidays.add(dayOfYear(year, Calendar.NOVEMBER, Calendar.FRIDAY, 4));

    // christmas eve
    holidays.add(dayOfYear(year, Calendar.DECEMBER, 24));
    // christmas day
    holidays.add(dayOfYear(year, Calendar.DECEMBER, 25));
    // day after christmas
    holidays.add(dayOfYear(year, Calendar.DECEMBER, 26));

    // new years eve
    holidays.add(dayOfYear(year, Calendar.DECEMBER, 31));

    // mark the holiday set with the year, so on Jan 1 it will automatically
    // recalculate the holidays for next year
    holidays.add(year);
}

From source file:org.jasig.schedassist.model.CommonDateOperations.java

/**
 * Helper method to calculate the first week's end date.
 * //from  w w  w .  j  a v  a 2 s.c o  m
 * @param date
 * @return the number of days from date until the following Sunday
 */
public static int numberOfDaysUntilSunday(final Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
    int result = 7;
    switch (dayOfWeek) {
    case Calendar.SUNDAY:
        result = 7;
        break;
    case Calendar.MONDAY:
        result = 6;
        break;
    case Calendar.TUESDAY:
        result = 5;
        break;
    case Calendar.WEDNESDAY:
        result = 4;
        break;
    case Calendar.THURSDAY:
        result = 3;
        break;
    case Calendar.FRIDAY:
        result = 2;
        break;
    case Calendar.SATURDAY:
        result = 1;
        break;
    }
    return result;
}

From source file:org.apache.myfaces.examples.schedule.ScheduleExampleHandler.java

public void addSampleEntries(ActionEvent event) {
    if (model == null)
        return;/*  w w w  .  j a v a2 s  .  co m*/
    Calendar calendar = GregorianCalendar.getInstance();
    calendar.setTime(model.getSelectedDate());
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
    calendar.set(Calendar.HOUR_OF_DAY, 14);
    DefaultScheduleEntry entry1 = new DefaultScheduleEntry();
    // every entry in a schedule must have a unique id
    entry1.setId(RandomStringUtils.randomNumeric(32));
    entry1.setStartTime(calendar.getTime());
    calendar.add(Calendar.MINUTE, 45);
    entry1.setEndTime(calendar.getTime());
    entry1.setTitle("Test MyFaces schedule component");
    entry1.setSubtitle("my office");
    entry1.setDescription("We need to get this thing out of the sandbox ASAP");
    model.addEntry(entry1);
    DefaultScheduleEntry entry2 = new DefaultScheduleEntry();
    entry2.setId(RandomStringUtils.randomNumeric(32));
    // entry2 overlaps entry1
    calendar.add(Calendar.MINUTE, -20);
    entry2.setStartTime(calendar.getTime());
    calendar.add(Calendar.HOUR, 2);
    entry2.setEndTime(calendar.getTime());
    entry2.setTitle("Show schedule component to boss");
    entry2.setSubtitle("my office");
    entry2.setDescription("Convince him to get time to thoroughly test it");
    model.addEntry(entry2);
    DefaultScheduleEntry entry3 = new DefaultScheduleEntry();
    entry3.setId(RandomStringUtils.randomNumeric(32));
    calendar.add(Calendar.DATE, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 9);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    entry3.setStartTime(calendar.getTime());
    calendar.set(Calendar.HOUR_OF_DAY, 17);
    entry3.setEndTime(calendar.getTime());
    entry3.setTitle("Thoroughly test schedule component");
    model.addEntry(entry3);
    DefaultScheduleEntry entry4 = new DefaultScheduleEntry();
    entry4.setId(RandomStringUtils.randomNumeric(32));
    calendar.add(Calendar.MONTH, -1);
    calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
    calendar.set(Calendar.HOUR_OF_DAY, 11);
    entry4.setStartTime(calendar.getTime());
    calendar.set(Calendar.HOUR_OF_DAY, 14);
    entry4.setEndTime(calendar.getTime());
    entry4.setTitle("Long lunch");
    model.addEntry(entry4);
    DefaultScheduleEntry entry5 = new DefaultScheduleEntry();
    entry5.setId(RandomStringUtils.randomNumeric(32));
    calendar.add(Calendar.MONTH, 2);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 1);
    entry5.setStartTime(calendar.getTime());
    calendar.set(Calendar.HOUR_OF_DAY, 5);
    entry5.setEndTime(calendar.getTime());
    entry5.setTitle("Fishing trip");
    model.addEntry(entry5);
    //Let's add a zero length entry...
    DefaultScheduleEntry entry6 = new DefaultScheduleEntry();
    calendar.setTime(model.getSelectedDate());
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
    calendar.set(Calendar.HOUR_OF_DAY, 16);
    entry6.setId(RandomStringUtils.randomNumeric(32));
    entry6.setStartTime(calendar.getTime());
    entry6.setEndTime(calendar.getTime());
    entry6.setTitle("Zero length entry");
    entry6.setDescription("Is only rendered when the 'renderZeroLengthEntries' attribute is 'true'");
    model.addEntry(entry6);
    //And also an allday event
    DefaultScheduleEntry entry7 = new DefaultScheduleEntry();
    entry7.setId(RandomStringUtils.randomNumeric(32));
    entry7.setTitle("All day event");
    entry7.setSubtitle("This event renders as an all-day event");
    entry7.setAllDay(true);
    model.addEntry(entry7);
    model.refresh();
}

From source file:com.clustercontrol.jobmanagement.factory.JobPlanSchedule.java

/**
 * ????Cron??//ww w  .j a  v  a  2s  . c  o m
 * 
 * @param cron
 */
private void createPlan(String cron) {

    /*
     * cron
     *       
     */

    // * 0 15 * * ? *         1500
    // * 0 23 ? * 1 *         2300
    // * */10 * * * ? *       10??

    String[] planSplit = cron.split(" ");
    String aster = "*";
    String question = "?";
    String slash = "/";
    if (!aster.equals(planSplit[0])) {
        secondType = 0;
        second = Integer.parseInt(planSplit[0]);
    }
    if (!aster.equals(planSplit[1])) {
        String[] slashSplit = planSplit[1].split(slash);
        int num = 0;
        for (String str : slashSplit) {
            m_log.trace("slashSplit[ " + num + " ] =" + str);
            num++;
        }
        //p?q????
        if (slashSplit.length == 2) {
            minuteType = 3;
            minute = Integer.parseInt(slashSplit[0]);
            fromMinutes = Integer.parseInt(slashSplit[0]);
            everyMinutes = Integer.parseInt(slashSplit[1]);
        } else {
            minuteType = 0;
            minute = Integer.parseInt(planSplit[1]);
            m_log.debug("minuteType=" + minuteType);
            m_log.debug("minute=" + minute);
        }
    }
    if (!aster.equals(planSplit[2])) {
        hourType = 0;
        hour = Integer.parseInt(planSplit[2]);
    }
    if (question.equals(planSplit[3])) {
        dayType = 2;
    } else if (!aster.equals(planSplit[3])) {
        dayType = 0;
        day = Integer.parseInt(planSplit[3]);
    }
    if (!aster.equals(planSplit[4])) {
        monthType = 0;
        month = Integer.parseInt(planSplit[4]);
    }
    if (question.equals(planSplit[5])) {
        weekType = 2;
    } else if (!aster.equals(planSplit[5])) {
        weekType = 0;
        week = Integer.parseInt(planSplit[5]);
    }
    switch (week) {
    case 1:
        weekCalendar = Calendar.SUNDAY;
        break;
    case 2:
        weekCalendar = Calendar.MONDAY;
        break;
    case 3:
        weekCalendar = Calendar.TUESDAY;
        break;
    case 4:
        weekCalendar = Calendar.WEDNESDAY;
        break;
    case 5:
        weekCalendar = Calendar.THURSDAY;
        break;
    case 6:
        weekCalendar = Calendar.FRIDAY;
        break;
    case 7:
        weekCalendar = Calendar.SATURDAY;
        break;
    default:
        weekCalendar = Calendar.SUNDAY;
    }
    // weekType?0??????????
    // ??????????*????0?? 
    if (weekType == 0 && isFireDayOfWeek() == false) {
        nextFireDay();
        if (hourType == 1) {
            hour = 0;
        }
    }
}

From source file:org.betaconceptframework.astroboa.portal.utility.CalendarUtils.java

public Calendar[] getCurrentWeekendPeriod(TimeZone zone, Locale locale) {
    Calendar weekendStart = GregorianCalendar.getInstance(zone, locale);
    Calendar weekendEnd = GregorianCalendar.getInstance(zone, locale);

    // we will include Friday in the weekend
    int currentDayOfWeek = weekendStart.get(Calendar.DAY_OF_WEEK);

    if (currentDayOfWeek == Calendar.FRIDAY) {
        // set to SUNDAY
        weekendEnd.add(Calendar.DAY_OF_MONTH, 2);
    } else if (currentDayOfWeek == Calendar.SATURDAY) {
        // set to SUNDAY
        weekendEnd.add(Calendar.DAY_OF_MONTH, 1);
    } else if (currentDayOfWeek == Calendar.SUNDAY) {
        //Do nothing
    } else {//ww  w  .  jav  a  2 s .  co  m
        while (weekendStart.get(Calendar.DAY_OF_WEEK) != Calendar.FRIDAY) {
            weekendStart.add(Calendar.DAY_OF_MONTH, 1);
            weekendEnd.add(Calendar.DAY_OF_MONTH, 1);
        }

        // now weekendStart and weekendEnd is FRIDAY and we 
        // set weekendEnd to SUNDAY
        weekendEnd.add(Calendar.DAY_OF_MONTH, 2);

    }

    setCalendarToStartOfDay(weekendStart);
    setCalendarToEndOfDay(weekendEnd);

    Calendar[] period = { weekendStart, weekendEnd };
    return period;
}

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

private void generateDrawerGreeting(NavigationView view) {
    View header = view.getHeaderView(0);
    TextView greeting = (TextView) header.findViewById(R.id.ndrawer_date_greeting);
    String[] array = this.getResources().getStringArray(R.array.drawer_greeting);

    switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) {
    case Calendar.MONDAY:
        greeting.setText(array[0]);//w w w.j  a v  a  2 s. c  om
        break;

    case Calendar.TUESDAY:
        greeting.setText(array[1]);
        break;

    case Calendar.WEDNESDAY:
        greeting.setText(array[2]);
        break;
    case Calendar.THURSDAY:
        greeting.setText(array[3]);
        break;
    case Calendar.FRIDAY:
        greeting.setText(array[4]);
        break;
    case Calendar.SATURDAY:
        greeting.setText(array[5]);
        break;

    case Calendar.SUNDAY:
        greeting.setText(array[6]);
        break;

    default:
        greeting.setText(array[7]);
        break;

    }

}

From source file:com.eryansky.common.utils.SysUtils.java

public static String getNowDateStr() {
     String result = dateFormat(getNowDate(), CHS_DATEFORMAT);
     Calendar c = Calendar.getInstance();
     for (int i = 0; i < 8; i++) {
         c.add(Calendar.DAY_OF_MONTH, 1);
         @SuppressWarnings("unused")
         int e = c.get(Calendar.DAY_OF_WEEK);
     }/*  w w  w.  j a va2  s  .com*/
     result += "  ";
     switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) {
     case Calendar.SUNDAY:
         return result + "";
     case Calendar.MONDAY:
         return result + "";
     case Calendar.TUESDAY:
         return result + "";
     case Calendar.WEDNESDAY:
         return result + "";
     case Calendar.THURSDAY:
         return result + "";
     case Calendar.FRIDAY:
         return result + "";
     case Calendar.SATURDAY:
         return result + "";
     default:
         return result;
     }
 }

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting day of week short description
 * //  w w w . jav  a 2s .c  om
 * @param dayOfWeek
 * @return
 */
public static String getDayOfWeekShortDesc(int dayOfWeek) {
    String dayOfWeekShortDesc;

    switch (dayOfWeek) {
    case Calendar.SUNDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_SUNDAY;
        break;
    }
    case Calendar.MONDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_MONDAY;
        break;
    }
    case Calendar.TUESDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_TUESDAY;
        break;
    }
    case Calendar.WEDNESDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_WEDNESDAY;
        break;
    }
    case Calendar.THURSDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_THURSDAY;
        break;
    }
    case Calendar.FRIDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_FRIDAY;
        break;
    }
    case Calendar.SATURDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_SATURDAY;
        break;
    }
    default: {
        dayOfWeekShortDesc = "";
        break;
    }
    }
    return dayOfWeekShortDesc;
}