List of usage examples for java.util Calendar FRIDAY
int FRIDAY
To view the source code for java.util Calendar FRIDAY.
Click Source Link
From source file:com.espertech.esper.regression.pattern.TestCronParameter.java
private int getLastWeekDayOfMonth(Integer day, int year) { int computeDay = (day == null) ? getLastDayOfMonth(year) : day; setTime(year);//w ww . jav a 2s .co m if (!checkDayValidInMonth(computeDay, calendar.get(Calendar.MONTH), calendar.get(Calendar.YEAR))) { throw new IllegalArgumentException("Invalid day for " + calendar.get(Calendar.MONTH)); } calendar.set(Calendar.DAY_OF_MONTH, computeDay); int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if ((dayOfWeek >= Calendar.MONDAY) && (dayOfWeek <= Calendar.FRIDAY)) { return computeDay; } if (dayOfWeek == Calendar.SATURDAY) { if (computeDay == 1) { calendar.add(Calendar.DAY_OF_MONTH, +2); } else { calendar.add(Calendar.DAY_OF_MONTH, -1); } } if (dayOfWeek == Calendar.SUNDAY) { if ((computeDay == 28) || (computeDay == 29) || (computeDay == 30) || (computeDay == 31)) { calendar.add(Calendar.DAY_OF_MONTH, -2); } else { calendar.add(Calendar.DAY_OF_MONTH, +2); } } return calendar.get(Calendar.DAY_OF_MONTH); }
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:// www . ja 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. * /*w w w .j a v a2 s .c o m*/ * @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 getFriday() { return daysOfWeek[Calendar.FRIDAY]; }
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. * //from www . j a v a 2 s . c o m * 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 ww w .ja va 2 s . c o 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:com.espertech.esper.schedule.ScheduleComputeHelper.java
private static boolean isWeekday(Calendar cal) { int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); return !(dayOfWeek < Calendar.MONDAY || dayOfWeek > Calendar.FRIDAY); }
From source file:org.ejbca.ui.web.admin.certprof.CertProfileBean.java
public boolean isExpirationRestrictionFriday() throws AuthorizationDeniedException { return getCertificateProfile().getExpirationRestrictionWeekday(Calendar.FRIDAY); }
From source file:de.ribeiro.android.gso.dataclasses.Pager.java
/** * Erstellt eine Stundeplan Seite des ViewPagers, inkl Header und Footer * <p/>/*from ww w .j av a 2 s . c o m*/ * Hier wird die Wochenansicht generiert * * @param weekData * @param ctxt * @return * @author Tobias Janssen */ private View createWeekPage(WeekData weekData) { // in die Page kommen alle Elemente dieser Ansicht View page = inflater.inflate(R.layout.weeklayout, null); TableLayout tl = (TableLayout) page.findViewById(R.id.weekTimetable); LinearLayoutBordered ll = new LinearLayoutBordered(context); // Tagesberschrift erstellen: TableRow tr = new TableRow(context); for (int x = Calendar.SUNDAY; x < Calendar.SATURDAY; x++) { // einen neuen Rahmen fr das Tabellenfeld vorbereiten ll = new LinearLayoutBordered(context); ll.setBorderRight(true); ll.setBorderBottom(true); ll.setBorderTop(true); ll.setBorderSize(1); ll.setBackgroundColor(Color.WHITE); View textview = inflater.inflate(R.layout.textview, null); TextView tv = (TextView) textview.findViewById(R.id.textview); // berschriftentextgre einstellen tv.setTextSize(textSize); if (x == Calendar.SUNDAY) { tv.setText(timeslots[0]); tv.setTextColor(Color.parseColor("#3A599A")); } else { tv.setText(ResolveWeekDay(x)); } ll.addView(tv); tr.addView(ll); } tl.addView(tr); // den Stundenplan zusammensetzten // fr jeden tag List<Lesson> stunden = GetSchulstunden(); for (int y = 0; y < stunden.size(); y++) { tr = new TableRow(context); for (int x = Calendar.SUNDAY; x <= Calendar.FRIDAY; x++) { if (x == Calendar.SUNDAY) { addColumn(timeslots[y + 1], "#3A599A", tr); } else { // alle events dieses Tages durchgehen ob die zu dieser // schulstunde passen boolean lessonAdded = false; TextView lastTextView = null; for (ICalEvent ev : weekData.events) { // ist event an diesem tag? if (ev.DTSTART.get(Calendar.DAY_OF_WEEK) == x) { // ja // ist event zu dieser schulstunde? Time st = new Time(); st.set(ev.DTSTART.getTimeInMillis()); int start = GetSchulstundeOfDateTime(st); Time et = new Time(); et.set(ev.DTEND.getTimeInMillis() - 60000); int end = GetSchulstundeOfDateTime(et); // ende der schulstunde herausfinden if (((start != end) && y >= start && y <= end) || start == y || end == y) { // ja event ist in dieser stunde // ist eine Doopelbelegung fr diese Stunde? if (lessonAdded && lastTextView != null) { // ja, doppelbelegung String newText = ""; if (weekData.typeId.equalsIgnoreCase("4")) { newText = lastTextView.getText() + "\r\n" + ev.DESCRIPTION + " " + ev.SUMMARY; } else { newText = lastTextView.getText() + "\r\n" + ev.DESCRIPTION.replace(weekData.elementId, "") + " " + ev.SUMMARY + " " + ev.LOCATION; } lastTextView.setText(newText); } else { // prfen, ob dieses event eine gelschte // stunde ist if (ev.UID.equalsIgnoreCase("deleted")) { // gelschtes event lastTextView = addColumn(" --- " + " " + " --- " + " " + " --- ", "#FF0000", tr); } else { String color = "#3A599A"; if (ev.UID.equalsIgnoreCase("diff")) color = "#FF0000"; if (weekData.typeId.equalsIgnoreCase("4")) { lastTextView = addColumn(ev.DESCRIPTION + " " + ev.SUMMARY, color, tr); } else { lastTextView = addColumn(ev.DESCRIPTION.replace(weekData.elementId, "") + " " + ev.SUMMARY + " " + ev.LOCATION, color, tr); } } } lessonAdded = true; } } } if (!lessonAdded) { // ja event ist in dieser stunde addColumn("", "#3A599A", tr); } } } tl.addView(tr); } TextView syncTime = (TextView) page.findViewById(R.id.syncTime); Calendar sync = new GregorianCalendar(); sync.setTimeInMillis(weekData.syncTime); String minute = String.valueOf(sync.get(Calendar.MINUTE)); if (minute.length() == 1) minute = "0" + minute; syncTime.setText(weekData.elementId + " | Stand vom " + sync.get(Calendar.DAY_OF_MONTH) + "." + (sync.get(Calendar.MONTH) + 1) + "." + sync.get(Calendar.YEAR) + " " + sync.get(Calendar.HOUR_OF_DAY) + ":" + minute + " Uhr"); return page; }
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 ww w .j a v a 2s . c om*/ // 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; }