Example usage for java.util Calendar SATURDAY

List of usage examples for java.util Calendar SATURDAY

Introduction

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

Prototype

int SATURDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Saturday.

Usage

From source file:org.apache.myfaces.custom.calendar.HtmlCalendarRenderer.java

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

    String[] localeWeekdays = symbols.getShortWeekdays();

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

    return weekdays;
}

From source file:org.apache.myfaces.custom.calendar.HtmlCalendarRenderer.java

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

    String[] localeWeekdays = symbols.getShortWeekdays();

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

    return weekdays;
}

From source file:com.autentia.tnt.bean.activity.ActivityBean.java

private void fillHolidays(SimpleScheduleModel model) {

    Calendar calMin = Calendar.getInstance();
    Calendar calMax = Calendar.getInstance();

    calMin = getMinimumSearchTime(selectedDate);
    calMax = getMaximumSearchTime(selectedDate);

    RequestHolidayManager rhManager = RequestHolidayManager.getDefault();
    RequestHolidaySearch rhSearch = new RequestHolidaySearch();
    rhSearch.setUserRequest(authManager.getCurrentPrincipal().getUser());
    rhSearch.setState(HolidayState.ACCEPT);
    rhSearch.setStartBeginDate(calMin.getTime());
    rhSearch.setEndBeginDate(calMax.getTime());
    rhSearch.setStartFinalDate(calMin.getTime());
    rhSearch.setEndFinalDate(calMax.getTime());

    List<RequestHoliday> listH = rhManager.getAllEntities(rhSearch, null);

    for (RequestHoliday rH : listH) {
        Calendar cActual = Calendar.getInstance();
        cActual.setTime(rH.getBeginDate());
        while (!cActual.getTime().after(rH.getFinalDate())) {
            if (cActual.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY
                    && cActual.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                model.setHoliday(cActual.getTime(), FacesUtils.getMessage("activity.acceptedHolidays"));
            }/*from w ww. j a va  2 s. c o m*/
            cActual.add(Calendar.DAY_OF_MONTH, 1);
        }

    }

    HolidaySearch monthSearch = new HolidaySearch();

    monthSearch.setStartDate(calMin.getTime());
    monthSearch.setEndDate(calMax.getTime());
    List<Holiday> listaHolidays = holidayManager.getAllEntities(monthSearch, null);

    for (Holiday holiday : listaHolidays) {
        model.setHoliday(holiday.getDate(), holiday.getDescription());
    }

}

From source file:org.apache.myfaces.custom.calendar.HtmlCalendarRenderer.java

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

    String[] localeWeekdays = symbols.getWeekdays();

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

    return weekdays;
}

From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java

private static String[] mapWeekdays(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:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java

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

    String[] localeWeekdays = symbols.getWeekdays();

    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:edu.jhuapl.openessence.controller.ReportController.java

private int getCalWeekStartDay(Map<String, ResolutionHandler> resolutionHandlers) {
    ResolutionHandler handler = resolutionHandlers.get("weekly");
    int startDay;
    if (handler == null || !(handler instanceof PgSqlWeeklyHandler)) {
        switch (Integer.parseInt(messageSource.getMessage("epidemiological.day.start",
                Integer.toString(DEFAULT_WEEK_STARTDAY)))) {
        case 0:/*from   w ww  . j a  va 2  s .  c  om*/
            startDay = Calendar.SUNDAY;
            break;
        case 2:
            startDay = Calendar.TUESDAY;
            break;
        case 3:
            startDay = Calendar.WEDNESDAY;
            break;
        case 4:
            startDay = Calendar.THURSDAY;
            break;
        case 5:
            startDay = Calendar.FRIDAY;
            break;
        case 6:
            startDay = Calendar.SATURDAY;
            break;
        default:
            startDay = Calendar.MONDAY;
            break;
        }
        return startDay;
    }
    return ((PgSqlWeeklyHandler) handler).getCalWeekStartDay();
}

From source file:org.unitime.timetable.solver.studentsct.StudentSectioningDatabaseLoader.java

private String datePatternName(DatePattern dp, TimeLocation time) {
    if ("never".equals(iDatePatternFormat))
        return dp.getName();
    if ("extended".equals(iDatePatternFormat) && dp.getType() != DatePattern.sTypeExtended)
        return dp.getName();
    if ("alternate".equals(iDatePatternFormat) && dp.getType() == DatePattern.sTypeAlternate)
        return dp.getName();
    if (time.getWeekCode().isEmpty())
        return time.getDatePatternName();
    Calendar cal = Calendar.getInstance(Locale.US);
    cal.setLenient(true);/* ww w. jav a2  s.  com*/
    cal.setTime(iDatePatternFirstDate);
    int idx = time.getWeekCode().nextSetBit(0);
    cal.add(Calendar.DAY_OF_YEAR, idx);
    Date first = null;
    while (idx < time.getWeekCode().size() && first == null) {
        if (time.getWeekCode().get(idx)) {
            int dow = cal.get(Calendar.DAY_OF_WEEK);
            switch (dow) {
            case Calendar.MONDAY:
                if ((time.getDayCode() & DayCode.MON.getCode()) != 0)
                    first = cal.getTime();
                break;
            case Calendar.TUESDAY:
                if ((time.getDayCode() & DayCode.TUE.getCode()) != 0)
                    first = cal.getTime();
                break;
            case Calendar.WEDNESDAY:
                if ((time.getDayCode() & DayCode.WED.getCode()) != 0)
                    first = cal.getTime();
                break;
            case Calendar.THURSDAY:
                if ((time.getDayCode() & DayCode.THU.getCode()) != 0)
                    first = cal.getTime();
                break;
            case Calendar.FRIDAY:
                if ((time.getDayCode() & DayCode.FRI.getCode()) != 0)
                    first = cal.getTime();
                break;
            case Calendar.SATURDAY:
                if ((time.getDayCode() & DayCode.SAT.getCode()) != 0)
                    first = cal.getTime();
                break;
            case Calendar.SUNDAY:
                if ((time.getDayCode() & DayCode.SUN.getCode()) != 0)
                    first = cal.getTime();
                break;
            }
        }
        cal.add(Calendar.DAY_OF_YEAR, 1);
        idx++;
    }
    if (first == null)
        return time.getDatePatternName();
    cal.setTime(iDatePatternFirstDate);
    idx = time.getWeekCode().length() - 1;
    cal.add(Calendar.DAY_OF_YEAR, idx);
    Date last = null;
    while (idx >= 0 && last == null) {
        if (time.getWeekCode().get(idx)) {
            int dow = cal.get(Calendar.DAY_OF_WEEK);
            switch (dow) {
            case Calendar.MONDAY:
                if ((time.getDayCode() & DayCode.MON.getCode()) != 0)
                    last = cal.getTime();
                break;
            case Calendar.TUESDAY:
                if ((time.getDayCode() & DayCode.TUE.getCode()) != 0)
                    last = cal.getTime();
                break;
            case Calendar.WEDNESDAY:
                if ((time.getDayCode() & DayCode.WED.getCode()) != 0)
                    last = cal.getTime();
                break;
            case Calendar.THURSDAY:
                if ((time.getDayCode() & DayCode.THU.getCode()) != 0)
                    last = cal.getTime();
                break;
            case Calendar.FRIDAY:
                if ((time.getDayCode() & DayCode.FRI.getCode()) != 0)
                    last = cal.getTime();
                break;
            case Calendar.SATURDAY:
                if ((time.getDayCode() & DayCode.SAT.getCode()) != 0)
                    last = cal.getTime();
                break;
            case Calendar.SUNDAY:
                if ((time.getDayCode() & DayCode.SUN.getCode()) != 0)
                    last = cal.getTime();
                break;
            }
        }
        cal.add(Calendar.DAY_OF_YEAR, -1);
        idx--;
    }
    if (last == null)
        return time.getDatePatternName();
    Formats.Format<Date> dpf = Formats.getDateFormat(Formats.Pattern.DATE_PATTERN);
    return dpf.format(first) + (first.equals(last) ? "" : " - " + dpf.format(last));
}

From source file:org.finra.dm.dao.AbstractDaoTest.java

/**
 * Creates a list of expected partition value process dates for a specified range. Weekends are excluded.
 *
 * @param partitionKeyGroupName the partition key group name
 * @param startDate the start date of the range
 * @param endDate the end date of the range
 *
 * @return the list of expected partition value process dates
 *///w w  w.  j  a v a 2  s  .c o m
protected List<ExpectedPartitionValueEntity> createExpectedPartitionValueProcessDates(
        String partitionKeyGroupName, Calendar startDate, Calendar endDate) {
    // Initialize the list of expected partition values.
    List<String> expectedPartitionValues = new ArrayList<>();

    // Keep incrementing the start date until it is greater than the end date, or until we have 1000 dates to protect against having too many dates or an
    // infinite loop in case the end date is before the start date.
    for (int i = 0; i < 1000 && startDate.compareTo(endDate) <= 0; i++) {
        // Create and persist a new entity for the date if it does not fall on the weekend.
        if ((startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY)
                && (startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY)) {
            expectedPartitionValues
                    .add(new SimpleDateFormat(DmDao.DEFAULT_SINGLE_DAY_DATE_MASK).format(startDate.getTime()));
        }

        // Add one day to the calendar.
        startDate.add(Calendar.DAY_OF_MONTH, 1);
    }

    // Return the list of entities.
    return createExpectedPartitionValueEntities(partitionKeyGroupName, expectedPartitionValues);
}

From source file:org.finra.herd.dao.AbstractDaoTest.java

/**
 * Creates a list of expected partition value process dates for a specified range. Weekends are excluded.
 *
 * @param partitionKeyGroupName the partition key group name
 * @param startDate the start date of the range
 * @param endDate the end date of the range
 *
 * @return the list of expected partition value process dates
 *//*from w  w w.  jav a  2 s . c  om*/
protected List<ExpectedPartitionValueEntity> createExpectedPartitionValueProcessDates(
        String partitionKeyGroupName, Calendar startDate, Calendar endDate) {
    // Initialize the list of expected partition values.
    List<String> expectedPartitionValues = new ArrayList<>();

    // Keep incrementing the start date until it is greater than the end date, or until we have 1000 dates to protect against having too many dates or an
    // infinite loop in case the end date is before the start date.
    for (int i = 0; i < 1000 && startDate.compareTo(endDate) <= 0; i++) {
        // Create and persist a new entity for the date if it does not fall on the weekend.
        if ((startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY)
                && (startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY)) {
            expectedPartitionValues.add(
                    new SimpleDateFormat(HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK).format(startDate.getTime()));
        }

        // Add one day to the calendar.
        startDate.add(Calendar.DAY_OF_MONTH, 1);
    }

    // Return the list of entities.
    return createExpectedPartitionValueEntities(partitionKeyGroupName, expectedPartitionValues);
}