List of usage examples for java.util Calendar SATURDAY
int SATURDAY
To view the source code for java.util Calendar SATURDAY.
Click Source Link
From source file:com.panet.imeta.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.java
public static Object isWorkingDay(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext) { if (ArgList.length == 1) { try {//www . j a va2s . com if (isNull(ArgList[0])) return null; else if (isUndefined(ArgList[0])) return Context.getUndefinedValue(); else { java.util.Date dIn = (java.util.Date) Context.jsToJava(ArgList[0], java.util.Date.class); Calendar startDate = Calendar.getInstance(); startDate.setTime(dIn); if (startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) return Boolean.TRUE; return Boolean.FALSE; } } catch (Exception e) { return null; } } else { throw Context.reportRuntimeError("The function call isWorkingDay requires 1 argument."); } }
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. * /*www. j a v a2 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:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for checking whether the target date is weekend * //from w ww . ja v a 2 s .co m * @param tgtDate * @return */ public static boolean isWeekEnd(Date tgtDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(tgtDate); return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY ? true : false); }
From source file:org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.java
public static Object isWorkingDay(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext) { if (ArgList.length == 1) { try {/*from w ww . j a v a2 s .c o m*/ if (isNull(ArgList[0])) { return null; } else if (isUndefined(ArgList[0])) { return Context.getUndefinedValue(); } else { java.util.Date dIn = (java.util.Date) Context.jsToJava(ArgList[0], java.util.Date.class); Calendar startDate = Calendar.getInstance(); startDate.setTime(dIn); if (startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { return Boolean.TRUE; } return Boolean.FALSE; } } catch (Exception e) { return null; } } else { throw Context.reportRuntimeError("The function call isWorkingDay requires 1 argument."); } }
From source file:de.ribeiro.android.gso.dataclasses.Pager.java
/** * Erstellt eine Stundeplan Seite des ViewPagers, inkl Header und Footer * <p/>// www. j ava 2s.co 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:org.everit.jira.timetracker.plugin.JiraTimetrackerPluginImpl.java
@Override public List<Date> getDates(final String selectedUser, final Date from, final Date to, final boolean workingHour, final boolean checkNonWorking) throws GenericEntityException { List<Date> datesWhereNoWorklog = new ArrayList<Date>(); Calendar fromDate = Calendar.getInstance(); fromDate.setTime(from);//from w w w. j a v a2s . c o m Calendar toDate = Calendar.getInstance(); toDate.setTime(to); while (!fromDate.after(toDate)) { String currentDateString = DateTimeConverterUtil.dateToString(fromDate.getTime()); if (excludeDatesSet.contains(currentDateString)) { fromDate.add(Calendar.DATE, 1); continue; } // check includes - not check weekend // check weekend - pass if (!includeDatesSet.contains(currentDateString) && ((fromDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) || (fromDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY))) { fromDate.add(Calendar.DATE, 1); continue; } // check worklog. if no worklog set result else ++ scanedDate boolean isDateContainsWorklog; if (workingHour) { isDateContainsWorklog = isContainsEnoughWorklog(fromDate.getTime(), checkNonWorking); } else { isDateContainsWorklog = isContainsWorklog(fromDate.getTime()); } if (!isDateContainsWorklog) { datesWhereNoWorklog.add((Date) fromDate.getTime().clone()); } fromDate.add(Calendar.DATE, 1); } Collections.reverse(datesWhereNoWorklog); return datesWhereNoWorklog; }
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 a v a2 s .c o m */ 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:org.ejbca.ui.web.admin.certprof.CertProfileBean.java
public boolean isExpirationRestrictionSaturday() throws AuthorizationDeniedException { return getCertificateProfile().getExpirationRestrictionWeekday(Calendar.SATURDAY); }
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"); }/* ww w. ja v a 2s.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.cognizant.trumobi.em.Email.java
public static String getWeekDays() { Calendar cal = Calendar.getInstance(); String string = Email.getPresentDay(); // Log.e("getPresentDay", ""+string); Date date = null;/* w w w.j a va 2 s . co m*/ try { date = new SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH).parse(string); } catch (ParseException e) { e.printStackTrace(); } cal.setTime(date); SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.US); Calendar firstCal = (Calendar) cal.clone(); firstCal.add(Calendar.DAY_OF_WEEK, firstCal.getFirstDayOfWeek() - firstCal.get(Calendar.DAY_OF_WEEK)); // SharedPreferences prefs = PreferenceManager // .getDefaultSharedPreferences(appContext); SharedPreferences prefs = new SharedPreferences(appContext); String WeekStartsOn = prefs.getString(appContext.getString(R.string.key_list_preference), ""); if (WeekStartsOn.equalsIgnoreCase("2")) { firstCal.setFirstDayOfWeek(Calendar.SATURDAY); } else if (WeekStartsOn.equalsIgnoreCase("3")) { firstCal.setFirstDayOfWeek(Calendar.SUNDAY); } else if (WeekStartsOn.equalsIgnoreCase("4")) { firstCal.setFirstDayOfWeek(Calendar.MONDAY); } int firstDayOfWeek = firstCal.getFirstDayOfWeek(); int dayOfWeek = firstCal.get(Calendar.DAY_OF_WEEK); if (firstDayOfWeek == 7) { firstCal.add(Calendar.DAY_OF_WEEK, -dayOfWeek); } else firstCal.add(Calendar.DAY_OF_WEEK, firstCal.getFirstDayOfWeek() - firstCal.get(Calendar.DAY_OF_WEEK)); String[] days = new String[2]; days[0] = format.format(firstCal.getTime()); Calendar lastCal = (Calendar) firstCal.clone(); lastCal.add(Calendar.DAY_OF_YEAR, 6); days[1] = format.format(lastCal.getTime()); String[] weekDays = Arrays.toString(days).split(","); // String weekVal2=weekDays[1].substring(weekDays[1].length()-1); String weekVal2 = weekDays[1].replace("]", ""); String weekVal = weekDays[0].substring(1) + " - " + weekVal2; return weekVal; }