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.ribeiro.android.gso.dataclasses.Pager.java

private String ResolveWeekDay(int value) {
    switch (value) {
    case Calendar.MONDAY:
        return "Montag";
    case Calendar.TUESDAY:
        return "Dienstag";
    case Calendar.WEDNESDAY:
        return "Mittwoch";
    case Calendar.THURSDAY:
        return "Donnerstag";
    case Calendar.FRIDAY:
        return "Freitag";
    case Calendar.SATURDAY:
        return "Samstag";
    case Calendar.SUNDAY:
        return "Sonntag";
    default://from  w ww. j a v a2  s  .  c o  m
        return String.valueOf(value);
    }

}

From source file:Time.java

/**
 * Get default locale name of this day ("Monday", "Tuesday", etc.
 * /*from   w w  w  .j a v  a2 s.c om*/
 * @return Name of day.
 */
public String getDayName() {
    switch (getDayOfWeek()) {
    case Calendar.MONDAY:
        return "Monday";
    case Calendar.TUESDAY:
        return "Tuesday";
    case Calendar.WEDNESDAY:
        return "Wednesday";
    case Calendar.THURSDAY:
        return "Thursday";
    case Calendar.FRIDAY:
        return "Friday";
    case Calendar.SATURDAY:
        return "Saturday";
    case Calendar.SUNDAY:
        return "Sunday";
    }

    // This will never happen
    return null;
}

From source file:org.sakaiproject.tool.section.jsf.backingbean.AddSectionsBean.java

public String getWednesday() {
    return daysOfWeek[Calendar.WEDNESDAY];
}

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

/**
 * Returns a {@link List} of {@link Date} objects that fall between startDate and endDate and
 * exist on the days specified by daysOfWeekPhrase.
 * /*w ww . java  2 s .  com*/
 * For instance, passing "MWF", a start Date of June 30 2008, and an end Date of July 04 2008, this 
 * method will return a list of 3 Date objects (one for Monday June 30, one for Wednesday July 2, and
 * one for Friday July 4).
 * 
 * The time values for returned {@link Date}s will always be 00:00:00 (in the JVM's default timezone).
 * 
 * @param daysOfWeekPhrase
 * @param startDate
 * @param endDate
 * @return a {@link List} of {@link Date} objects that fall between startDate and endDate and
 * exist on the days specified by daysOfWeekPhrase.
 */
protected static List<Date> matchingDays(final String daysOfWeekPhrase, final Date startDate,
        final Date endDate) {
    List<Date> matchingDays = new ArrayList<Date>();

    Set<Integer> daysOfWeek = new HashSet<Integer>();
    for (char character : daysOfWeekPhrase.toUpperCase().toCharArray()) {
        switch (character) {
        case 'N':
            daysOfWeek.add(Calendar.SUNDAY);
            break;
        case 'M':
            daysOfWeek.add(Calendar.MONDAY);
            break;
        case 'T':
            daysOfWeek.add(Calendar.TUESDAY);
            break;
        case 'W':
            daysOfWeek.add(Calendar.WEDNESDAY);
            break;
        case 'R':
            daysOfWeek.add(Calendar.THURSDAY);
            break;
        case 'F':
            daysOfWeek.add(Calendar.FRIDAY);
            break;
        case 'S':
            daysOfWeek.add(Calendar.SATURDAY);
            break;
        }
    }

    Calendar current = Calendar.getInstance();
    current.setTime(startDate);
    // set the time to 00:00:00 to insure the time doesn't affect our comparison)
    // (because there may be a valid time window on endDate)
    current = CommonDateOperations.zeroOutTimeFields(current);

    while (current.getTime().compareTo(endDate) < 0) {
        if (daysOfWeek.contains(current.get(Calendar.DAY_OF_WEEK))) {
            matchingDays.add(current.getTime());
        }
        // increment currentDate +1 day 
        current.add(Calendar.DATE, 1);
    }
    return matchingDays;
}

From source file:org.kuali.student.r2.core.scheduling.service.impl.TestSchedulingServiceImpl.java

@Test
public void testgetTimeSlotsByIds() throws Exception {
    // test case: all valid ids
    List<String> valid_ids = new ArrayList<String>();
    valid_ids.add("ts102");
    valid_ids.add("ts115");
    List<TimeSlotInfo> l_valid_ts = schedulingService.getTimeSlotsByIds(valid_ids, contextInfo);
    assertEquals(2, valid_ids.size());//from  w ww . j  ava2 s.  co  m

    TimeSlot ts2 = null, ts15 = null;
    // ensure the list has only time slots with ids 2 and 15
    for (TimeSlotInfo ts : l_valid_ts) {
        assertTrue(valid_ids.contains(ts.getId()));
        if (ts.getId().equals("ts102")) {
            ts2 = ts;
        } else {
            ts15 = ts;
        }
    }

    assertNotNull(ts2);
    assertEquals("ts102", ts2.getId());
    List<Integer> dow = ts2.getWeekdays();
    // should contain Monday, Wednesday, Friday
    assertTrue(dow.contains(Calendar.MONDAY));
    assertTrue(dow.contains(Calendar.WEDNESDAY));
    assertTrue(dow.contains(Calendar.FRIDAY));
    // should not contain Tuesday or Thursday
    assertFalse(dow.contains(Calendar.TUESDAY));
    assertFalse(dow.contains(Calendar.THURSDAY));
    assertEquals(ts2.getStartTime(), TOD_8_AM);
    assertEquals(ts2.getEndTime(), TOD_9_10_AM);

    assertNotNull(ts15);
    assertEquals("ts115", ts15.getId());
    dow = ts15.getWeekdays();
    // should not contain Monday, Wednesday, Friday
    assertFalse(dow.contains(Calendar.MONDAY));
    assertFalse(dow.contains(Calendar.WEDNESDAY));
    assertFalse(dow.contains(Calendar.FRIDAY));
    // should contain Tuesday or Thursday
    assertTrue(dow.contains(Calendar.TUESDAY));
    assertTrue(dow.contains(Calendar.THURSDAY));
    assertEquals(ts15.getStartTime(), TOD_3_PM);
    assertEquals(ts15.getEndTime(), TOD_3_50_PM);

    // test case: all invalid ids
    List<String> invalid_ids = new ArrayList<String>();
    invalid_ids.add("bad1");
    invalid_ids.add("bad2");
    try {
        schedulingService.getTimeSlotsByIds(invalid_ids, contextInfo);
        fail("Should not be here - test invalid_ids");
    } catch (DoesNotExistException e) {
        assertNotNull(e.getMessage());
        assertEquals("No data was found for : bad1, bad2", e.getMessage());
    }

    // test case: mixture of valid and invalid
    List<String> mix_ids = new ArrayList<String>();
    mix_ids.add("ts110");
    mix_ids.add("bad1");
    try {
        schedulingService.getTimeSlotsByIds(mix_ids, contextInfo);
        fail("Should not be here - test mix_ids");
    } catch (DoesNotExistException e) {
        assertNotNull(e.getMessage());
        assertEquals("Missing data for : bad1", e.getMessage());
    }
}

From source file:org.ejbca.ui.web.admin.certprof.CertProfileBean.java

public boolean isExpirationRestrictionWednesday() throws AuthorizationDeniedException {
    return getCertificateProfile().getExpirationRestrictionWeekday(Calendar.WEDNESDAY);
}

From source file:com.embeddedlog.LightUpDroid.LightUpPiSync.java

private Alarm alarmFromJson(JSONObject aJson) {
    // If mSelectedAlarm is null then we're creating a new alarm.
    Alarm alarm = new Alarm();
    alarm.alert = RingtoneManager.getActualDefaultRingtoneUri(mActivityContext, RingtoneManager.TYPE_ALARM);
    if (alarm.alert == null) {
        alarm.alert = Uri.parse("content://settings/system/alarm_alert");
    }//from   w w  w.j  av a 2 s  .  co  m
    // Setting the vibrate option to always true, as there is no attribute in LightUpPi
    alarm.vibrate = true;
    // Setting the 'delete after use' option to always false, as there is no such feature in
    // the LightUpPi alarm system and all alarms are repeatable
    alarm.deleteAfterUse = false;

    // Parsing the JSON data
    try {
        alarm.hour = aJson.getInt("hour");
        alarm.minutes = aJson.getInt("minute");
        alarm.enabled = aJson.getBoolean("enabled");
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("monday"), Calendar.MONDAY);
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("tuesday"), Calendar.TUESDAY);
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("wednesday"), Calendar.WEDNESDAY);
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("thursday"), Calendar.THURSDAY);
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("friday"), Calendar.FRIDAY);
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("saturday"), Calendar.SATURDAY);
        alarm.daysOfWeek.setDaysOfWeek(aJson.getBoolean("sunday"), Calendar.SUNDAY);
        alarm.label = aJson.getString("label");
        alarm.lightuppiId = aJson.getLong("id");
        alarm.timestamp = aJson.getLong("timestamp");
    } catch (JSONException e) {
        Log.w(LOG_TAG + " JSONException: " + e.toString());
        alarm = null;
    }
    return alarm;
}

From source file:com.customdatepicker.date.MonthView.java

/**
 * Return a 1 or 2 letter String for use as a weekday label
 *
 * @param day The day for which to generate a label
 * @return The weekday label//  w  w w  . j av  a 2  s. c om
 */
private String getWeekDayLabel(Calendar day) {
    Locale locale = Locale.getDefault();

    // Localised short version of the string is not available on API < 18
    if (Build.VERSION.SDK_INT < 18) {
        String dayName = new SimpleDateFormat("E", locale).format(day.getTime());
        String dayLabel = dayName.toUpperCase(locale).substring(0, 1);

        // Chinese labels should be fetched right to left
        if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE)
                || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) {
            int len = dayName.length();
            dayLabel = dayName.substring(len - 1, len);
        }

        // Most hebrew labels should select the second to last character
        if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) {
            if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
                int len = dayName.length();
                dayLabel = dayName.substring(len - 2, len - 1);
            } else {
                // I know this is duplication, but it makes the code easier to grok by
                // having all hebrew code in the same block
                dayLabel = dayName.toUpperCase(locale).substring(0, 1);
            }
        }

        // Catalan labels should be two digits in lowercase
        if (locale.getLanguage().equals("ca"))
            dayLabel = dayName.toLowerCase().substring(0, 2);

        // Correct single character label in Spanish is X
        if (locale.getLanguage().equals("es") && day.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
            dayLabel = "X";

        return dayLabel;
    }
    // Getting the short label is a one liner on API >= 18
    if (weekDayLabelFormatter == null) {
        weekDayLabelFormatter = new SimpleDateFormat("EEEEE", locale);
    }
    return weekDayLabelFormatter.format(day.getTime());
}

From source file:com.sonyericsson.hudson.plugins.gerrit.trigger.config.Config.java

/**
 * Adds the WatchTimeExceptionData from the form.
 *
 * @param formData the form./*from  w ww .j  av a  2 s .  com*/
 * @return the WatchTimeExceptionData
 */
private WatchTimeExceptionData addWatchTimeExceptionData(JSONObject formData) {
    List<Integer> days = new LinkedList<Integer>();
    List<TimeSpan> exceptionTimes = new LinkedList<TimeSpan>();
    int[] daysAsInt = new int[] {};
    if (formData.has("watchdogExceptions")) {
        JSONObject jsonObject = formData.getJSONObject(("watchdogExceptions"));
        if (jsonObject.getBoolean(String.valueOf(Calendar.MONDAY))) {
            days.add(Calendar.MONDAY);
        }
        if (jsonObject.getBoolean(String.valueOf(Calendar.TUESDAY))) {
            days.add(Calendar.TUESDAY);
        }
        if (jsonObject.getBoolean(String.valueOf(Calendar.WEDNESDAY))) {
            days.add(Calendar.WEDNESDAY);
        }
        if (jsonObject.getBoolean(String.valueOf(Calendar.THURSDAY))) {
            days.add(Calendar.THURSDAY);
        }
        if (jsonObject.getBoolean(String.valueOf(Calendar.FRIDAY))) {
            days.add(Calendar.FRIDAY);
        }
        if (jsonObject.getBoolean(String.valueOf(Calendar.SATURDAY))) {
            days.add(Calendar.SATURDAY);
        }
        if (jsonObject.getBoolean(String.valueOf(Calendar.SUNDAY))) {
            days.add(Calendar.SUNDAY);
        }
        daysAsInt = Ints.toArray(days);
        if (jsonObject.has("watchdogExceptionTimes")) {
            Object obj = jsonObject.get("watchdogExceptionTimes");
            if (obj instanceof JSONArray) {
                for (Object json : (JSONArray) obj) {
                    exceptionTimes.add(TimeSpan.createTimeSpanFromJSONObject((JSONObject) json));
                }
            } else if (obj instanceof JSONObject) {
                exceptionTimes.add(TimeSpan.createTimeSpanFromJSONObject((JSONObject) obj));
            }
        }
    }
    return new WatchTimeExceptionData(daysAsInt, exceptionTimes);
}

From source file:org.ejbca.ui.web.admin.certprof.CertProfileBean.java

public void setExpirationRestrictionWednesday(final boolean enabled) throws AuthorizationDeniedException {
    getCertificateProfile().setExpirationRestrictionWeekday(Calendar.WEDNESDAY, enabled);
}