List of usage examples for java.util Calendar MONDAY
int MONDAY
To view the source code for java.util Calendar MONDAY.
Click Source Link
From source file:fr.paris.lutece.plugins.calendar.web.CalendarApp.java
/** * Get the XPage for getting the search result * @param request {@link HttpServletRequest} * @param plugin {@link Plugin}/*from w w w . j av a2 s . c o m*/ * @return the html * @throws SiteMessageException message if error */ private XPage getSearchResultPage(HttpServletRequest request, Plugin plugin) throws SiteMessageException { String strQuery = request.getParameter(Constants.PARAMETER_QUERY); String[] arrayCategory = request.getParameterValues(Constants.PARAMETER_CATEGORY); String[] arrayCalendar = request.getParameterValues(Constants.PARAMETER_CALENDAR_ID); String strDateBegin = request.getParameter(Constants.PARAMETER_DATE_START); String strDateEnd = request.getParameter(Constants.PARAMETER_DATE_END); String strPeriod = request.getParameter(Constants.PARAMETER_PERIOD); if (StringUtils.isBlank(strPeriod) || !StringUtils.isNumeric(strPeriod)) { strPeriod = Integer.toString(Constants.PROPERTY_PERIOD_NONE); } String strAgenda = null; String strBaseUrl = AppPathService.getBaseUrl(request); UrlItem url = new UrlItem(JSP_PAGE_PORTAL); url.addParameter(Constants.PARAMETER_QUERY, strQuery == null ? Constants.EMPTY_STRING : strQuery); url.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); url.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_DO_SEARCH); if (arrayCalendar != null) { for (String strAgendaId : arrayCalendar) { url.addParameter(Constants.PARAMETER_CALENDAR_ID, strAgendaId); } } else { arrayCalendar = Utils.getCalendarIds(request); } url.addParameter(Constants.PARAMETER_DATE_START, strDateBegin); url.addParameter(Constants.PARAMETER_DATE_END, strDateEnd); url.addParameter(Constants.PARAMETER_PERIOD, strPeriod); List<Event> listEvent = null; Date dateBegin = null; Date dateEnd = null; switch (Integer.parseInt(strPeriod)) { case Constants.PROPERTY_PERIOD_NONE: break; case Constants.PROPERTY_PERIOD_TODAY: dateBegin = new Date(); dateEnd = new Date(); strDateBegin = DateUtil.getDateString(new Date(), request.getLocale()); strDateEnd = DateUtil.getDateString(new Date(), request.getLocale()); break; case Constants.PROPERTY_PERIOD_WEEK: Calendar calendar = new GregorianCalendar(); Calendar calendarFirstDay = new GregorianCalendar(); Calendar calendarLastDay = new GregorianCalendar(); int nDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if (nDayOfWeek == 1) { nDayOfWeek = 8; } calendarFirstDay = calendar; calendarFirstDay.add(Calendar.DATE, Calendar.MONDAY - nDayOfWeek); calendarLastDay = (GregorianCalendar) calendarFirstDay.clone(); calendarLastDay.add(Calendar.DATE, 6); dateBegin = calendarFirstDay.getTime(); dateEnd = calendarLastDay.getTime(); strDateBegin = DateUtil.getDateString(dateBegin, request.getLocale()); strDateEnd = DateUtil.getDateString(dateEnd, request.getLocale()); break; case Constants.PROPERTY_PERIOD_RANGE: if (StringUtils.isNotBlank(strDateBegin) && StringUtils.isNotBlank(strDateEnd)) { dateBegin = DateUtil.formatDate(strDateBegin, request.getLocale()); dateEnd = DateUtil.formatDate(strDateEnd, request.getLocale()); if (dateBegin == null || !Utils.isValidDate(dateBegin) || dateEnd == null || !Utils.isValidDate(dateEnd)) { errorDateFormat(request); } } else { errorDateFormat(request); } break; default: break; } listEvent = CalendarSearchService.getInstance().getSearchResults(arrayCalendar, arrayCategory, strQuery, dateBegin, dateEnd, plugin); _strCurrentPageIndex = Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex); _nItemsPerPage = Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage); if (listEvent == null) { listEvent = new ArrayList<Event>(); } Map<String, Object> model = new HashMap<String, Object>(); Paginator<Event> paginator = new Paginator<Event>(listEvent, _nItemsPerPage, url.getUrl(), Constants.PARAMETER_PAGE_INDEX, _strCurrentPageIndex); //if one calendar is selected if ((arrayCalendar != null) && (arrayCalendar.length == 1)) { strAgenda = arrayCalendar[0]; } UrlItem urlSubscription = new UrlItem(strBaseUrl + JSP_PAGE_PORTAL); urlSubscription.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); urlSubscription.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_GET_SUBSCRIPTION_PAGE); urlSubscription.addParameter(Constants.PARAM_AGENDA, strAgenda); UrlItem urlDownload = new UrlItem(strBaseUrl + JSP_PAGE_PORTAL); urlDownload.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); urlDownload.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_GET_DOWNLOAD_PAGE); UrlItem urlRss = new UrlItem(strBaseUrl + JSP_PAGE_RSS); urlRss.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_RSS); if (arrayCalendar != null) { for (String strAgendaId : arrayCalendar) { urlRss.addParameter(Constants.PARAMETER_CALENDAR_ID, strAgendaId); } } if (arrayCategory != null) { for (String strCategoryId : arrayCategory) { urlRss.addParameter(Constants.PARAMETER_CATEGORY, strCategoryId); } } ReferenceList listAgendas = getListAgenda(request, plugin); if (arrayCalendar != null) { listAgendas.checkItems(arrayCalendar); } Collection<Category> categoryList = _categoryService.getCategories(plugin); ReferenceList listCategorys = getReferenceListCategory(categoryList); if (arrayCategory != null) { listCategorys.checkItems(arrayCategory); } // Evol List occurrences List<List<OccurrenceEvent>> listOccurrences = new ArrayList<List<OccurrenceEvent>>(); for (Event event : listEvent) { List<OccurrenceEvent> listOccurrence = _eventListService.getOccurrenceEvents(event.getIdCalendar(), event.getId(), Constants.SORT_ASC, plugin); listOccurrences.add(listOccurrence); } CalendarUserOptions options = getUserOptions(request); options.setShowSearchEngine(Boolean.TRUE); boolean bIsSelectedDay = false; String strDate; if (StringUtils.isNotBlank(strDateBegin) && !Constants.NULL.equals(strDateBegin)) { strDate = Utils.getDate(DateUtil.formatDateLongYear(strDateBegin, request.getLocale())); if (strDateBegin.equals(strDateEnd)) { bIsSelectedDay = true; } } else { strDate = Utils.getDate(new Date()); } MultiAgenda agendaWithOccurences = _calendarService.getMultiAgenda(request); model.put(Constants.MARK_QUERY, (StringUtils.isNotBlank(strQuery)) ? strQuery : StringUtils.EMPTY); model.put(Constants.MARK_SUBSCRIPTION_PAGE, urlSubscription.getUrl()); model.put(Constants.MARK_DOWNLOAD_PAGE, urlDownload.getUrl()); model.put(Constants.MARK_RSS_PAGE, urlRss.getUrl()); model.put(Constants.MARK_DATE_START, (StringUtils.isNotBlank(strDateBegin)) ? strDateBegin : StringUtils.EMPTY); model.put(Constants.MARK_DATE_END, (StringUtils.isNotBlank(strDateEnd)) ? strDateEnd : StringUtils.EMPTY); model.put(Constants.MARK_PERIOD, (StringUtils.isNotBlank(strPeriod)) ? strPeriod : StringUtils.EMPTY); model.put(Constants.MARK_EVENTS_LIST, paginator.getPageItems()); model.put(Constants.MARK_PAGINATOR, paginator); model.put(Constants.MARK_NB_ITEMS_PER_PAGE, Integer.toString(_nItemsPerPage)); model.put(Constants.MARK_CALENDARS_LIST, listAgendas); model.put(Constants.MARK_AGENDA, (StringUtils.isNotBlank(strAgenda)) ? strAgenda : StringUtils.EMPTY); model.put(Constants.MARK_LOCALE, request.getLocale()); model.put(Constants.MARK_CATEGORY_LIST, listCategorys); model.put(Constants.MARK_OCCURRENCES_LIST, listOccurrences); model.put(Constants.MARK_SMALL_MONTH_CALENDAR, SmallMonthCalendar.getSmallMonthCalendar(strDate, agendaWithOccurences, options, bIsSelectedDay)); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DO_SEARCH_EVENTS, request.getLocale(), model); XPage page = new XPage(); page.setContent(template.getHtml()); page.setTitle( I18nService.getLocalizedString(Constants.PROPERTY_PAGE_TITLE_SEARCH_RESULT, request.getLocale())); page.setPathLabel( I18nService.getLocalizedString(Constants.PROPERTY_PAGE_TITLE_SEARCH, request.getLocale())); return page; }
From source file:org.apache.click.extras.control.DateField.java
/** * Return the first day of the week. For example e.g., Sunday in US, * Monday in France and Australia./*from w ww. j a v a 2 s . co m*/ * * @return the first day of the week */ protected int getFirstDayOfWeek() { Locale locale = getLocale(); if ("AU".equals(locale.getCountry())) { return Calendar.MONDAY; } Calendar calendar = Calendar.getInstance(locale); return calendar.getFirstDayOfWeek(); }
From source file:com.alkacon.opencms.calendar.CmsSerialDateWidget.java
/** * Returns the macro resolver with initialized macros to generate the serial date input form.<p> * //w w w . ja v a2 s . com * @param cms an initialized instance of a CmsObject * @param widgetDialog the dialog where the widget is used on * @param param the widget parameter to generate the widget for * @return the macro resolver with initialized macros */ protected CmsMacroResolver getMacroResolverForForm(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { CmsMacroResolver resolver = CmsMacroResolver.newInstance(); // set cms object and localized messages in resolver resolver.setCmsObject(cms); CmsMessages messages = new CmsMessages(CmsSerialDateWidget.class.getPackage().getName() + ".messages", widgetDialog.getLocale()); resolver.setMessages(messages); // delete empty macros which were not replaced resolver.setKeepEmptyMacros(false); // create the serial entry date object String paramValue = param.getStringValue(cms); Map params = CmsStringUtil.splitAsMap(paramValue, String.valueOf(CmsProperty.VALUE_LIST_DELIMITER), String.valueOf(CmsProperty.VALUE_MAP_DELIMITER)); // create the entry date from the field values CmsCalendarEntryDateSerial entryDate = CmsCalendarSerialDateFactory.getSerialDate(params, widgetDialog.getLocale()); if (entryDate == null) { // no entry date created yet, build an empty default date Calendar start = new GregorianCalendar(widgetDialog.getLocale()); Calendar end = (Calendar) start.clone(); entryDate = new CmsCalendarEntryDateSerial(start, end); entryDate.setSerialEndType(I_CmsCalendarSerialDateOptions.END_TYPE_NEVER); } // vars for daily options String dayDailyInterval = "1"; boolean dayEveryWorkingDay = false; // vars for weekly options String weekWeeklyInterval = "1"; // vars for monthly options int monthSelectedIndexWeekDayOfMonth = 0; int monthSelectedWeekDay = -1; String monthDayOfMonth = "1"; String monthMonthlyInterval = "1"; String monthMonthlyIntervalWeekDay = "1"; boolean monthUseWeekday = false; // vars for yearly options String yearDayOfMonth = "1"; boolean yearUseWeekday = false; int yearSelectedIndexMonth = 0; int yearSelectedIndexWeekDayOfMonth = 0; int yearSelectedWeekDayDay = -1; int yearSelectedIndexWeekDayMonth = 0; if (entryDate.getSerialOptions() != null) { // fill the variables depending on the selected serial date type String serialTypeMacroPrefix = MACRO_PREFIX_PARAMVALUE + PARAM_SERIALTYPE + "."; // set serial type radio selection resolver.addMacro(serialTypeMacroPrefix + entryDate.getSerialOptions().getSerialType(), ATTR_CHECKED); switch (entryDate.getSerialOptions().getSerialType()) { // set values for the selected serial type case I_CmsCalendarSerialDateOptions.TYPE_DAILY: CmsCalendarSerialDateDailyOptions dailyOptions = (CmsCalendarSerialDateDailyOptions) entryDate .getSerialOptions(); dayEveryWorkingDay = dailyOptions.isEveryWorkingDay(); dayDailyInterval = String.valueOf(dailyOptions.getDailyInterval()); break; case I_CmsCalendarSerialDateOptions.TYPE_WEEKLY: CmsCalendarSerialDateWeeklyOptions weeklyOptions = (CmsCalendarSerialDateWeeklyOptions) entryDate .getSerialOptions(); weekWeeklyInterval = String.valueOf(weeklyOptions.getWeeklyInterval()); // check the chosen week day checkboxes serialTypeMacroPrefix = MACRO_PREFIX_PARAMVALUE + PARAM_WEEK_WEEKDAY + "."; if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.MONDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.MONDAY, ATTR_CHECKED); } if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.TUESDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.TUESDAY, ATTR_CHECKED); } if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.WEDNESDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.WEDNESDAY, ATTR_CHECKED); } if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.THURSDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.THURSDAY, ATTR_CHECKED); } if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.FRIDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.FRIDAY, ATTR_CHECKED); } if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.SATURDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.SATURDAY, ATTR_CHECKED); } if (weeklyOptions.getWeekDays().contains(new Integer(Calendar.SUNDAY))) { resolver.addMacro(serialTypeMacroPrefix + Calendar.SUNDAY, ATTR_CHECKED); } break; case I_CmsCalendarSerialDateOptions.TYPE_MONTHLY: CmsCalendarSerialDateMonthlyOptions monthlyOptions = (CmsCalendarSerialDateMonthlyOptions) entryDate .getSerialOptions(); monthUseWeekday = monthlyOptions.isUseWeekDay(); if (!monthlyOptions.isUseWeekDay()) { monthDayOfMonth = String.valueOf(monthlyOptions.getDayOfMonth()); monthMonthlyInterval = String.valueOf(monthlyOptions.getMonthlyInterval()); } else { // set selected index of select boxes monthSelectedIndexWeekDayOfMonth = monthlyOptions.getDayOfMonth() - 1; monthSelectedWeekDay = monthlyOptions.getWeekDay(); monthMonthlyIntervalWeekDay = String.valueOf(monthlyOptions.getMonthlyInterval()); } break; case I_CmsCalendarSerialDateOptions.TYPE_YEARLY: CmsCalendarSerialDateYearlyOptions yearlyOptions = (CmsCalendarSerialDateYearlyOptions) entryDate .getSerialOptions(); yearUseWeekday = yearlyOptions.isUseWeekDay(); if (!yearlyOptions.isUseWeekDay()) { yearDayOfMonth = String.valueOf(yearlyOptions.getDayOfMonth()); yearSelectedIndexMonth = yearlyOptions.getMonth(); } else { yearSelectedIndexWeekDayOfMonth = yearlyOptions.getDayOfMonth() - 1; yearSelectedWeekDayDay = yearlyOptions.getWeekDay(); yearSelectedIndexWeekDayMonth = yearlyOptions.getMonth(); } break; default: // nothing do do here, should never happen } } else { // no serial entry created yet, add some defaults resolver.addMacro( MACRO_PREFIX_PARAMVALUE + PARAM_SERIALTYPE + "." + I_CmsCalendarSerialDateOptions.TYPE_DAILY, ATTR_CHECKED); resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_WEEK_WEEKDAY + "." + Calendar.MONDAY, ATTR_CHECKED); } // set time settings String startTime = getCalendarLocalizedTime(widgetDialog.getLocale(), widgetDialog.getMessages(), entryDate.getStartDate().getTimeInMillis(), false, true); resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_STARTTIME, startTime); String endTime = ""; if (!entryDate.getStartDate().equals(entryDate.getEndDate())) { // end time is different from start time, get localized value endTime = getCalendarLocalizedTime(widgetDialog.getLocale(), widgetDialog.getMessages(), entryDate.getEndDate().getTimeInMillis(), false, true); } resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_ENDTIME, endTime); resolver.addMacro("select.durationdays", buildSelectDurationDays(PARAM_DURATIONDAYS, messages, entryDate.getDuration())); // set found values to serial option tabs // daily options resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_DAY_DAILYINTERVAL, dayDailyInterval); resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_DAY_EVERYWORKINGDAY + "." + dayEveryWorkingDay, ATTR_CHECKED); // weekly options resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_WEEK_WEEKLYINTERVAL, weekWeeklyInterval); // monthly options // mark the correct radio resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_SERIALMONTHDAY + "." + monthUseWeekday, ATTR_CHECKED); // set the macros for the day of month options resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_DAYOFMONTH, monthDayOfMonth); resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_MONTHLYINTERVAL, monthMonthlyInterval); // set the macros for the week day of month options resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_MONTH_MONTHLYINTERVALWEEKDAY, monthMonthlyIntervalWeekDay); // build the select boxes resolver.addMacro("select.monthnumberofweekday", buildSelectNumberOfWeekDayOfMonth( PARAM_MONTH_NUMBEROFWEEKDAYOFMONTH, "onfocus=\"document.getElementById('" + PARAM_MONTH_SERIALMONTHDAY + ".true').checked = true;\"", messages, monthSelectedIndexWeekDayOfMonth)); resolver.addMacro("select.monthweekday", buildSelectWeekDay(PARAM_MONTH_WEEKDAY, "onfocus=\"document.getElementById('" + PARAM_MONTH_SERIALMONTHDAY + ".true').checked = true;\"", messages, monthSelectedWeekDay)); // yearly options // mark the correct radio resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_YEAR_SERIALYEARDAY + "." + yearUseWeekday, ATTR_CHECKED); // set the macros for the day of month options resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_YEAR_DAYOFMONTH, yearDayOfMonth); resolver.addMacro("select.yearmonth", buildSelectMonth(PARAM_YEAR_MONTH, "onfocus=\"document.getElementById('" + PARAM_YEAR_SERIALYEARDAY + ".false').checked = true;\"", messages, yearSelectedIndexMonth)); // set the macros for the week day of month options resolver.addMacro("select.yearnumberofweekday", buildSelectNumberOfWeekDayOfMonth(PARAM_YEAR_WEEKDAYOFMONTH, "onfocus=\"document.getElementById('" + PARAM_YEAR_SERIALYEARDAY + ".true').checked = true;\"", messages, yearSelectedIndexWeekDayOfMonth)); resolver.addMacro("select.yearweekday", buildSelectWeekDay(PARAM_YEAR_WEEKDAY, "onfocus=\"document.getElementById('" + PARAM_YEAR_SERIALYEARDAY + ".true').checked = true;\"", messages, yearSelectedWeekDayDay)); resolver.addMacro("select.yearmonthweekday", buildSelectMonth(PARAM_YEAR_WEEKDAYMONTH, "onfocus=\"document.getElementById('" + PARAM_YEAR_SERIALYEARDAY + ".true').checked = true;\"", messages, yearSelectedIndexWeekDayMonth)); // set serial duration values // set start date resolver.addMacro("calendar.startdate", buildDateInput("startdate", widgetDialog, entryDate.getStartDate())); Calendar serialEndDate = entryDate.getSerialEndDate(); if (serialEndDate == null) { serialEndDate = entryDate.getStartDate(); } resolver.addMacro("calendar.serialenddate", buildDateInput("serialenddate", widgetDialog, serialEndDate)); // set occurences int occurences = 10; if (entryDate.getSerialEndType() == I_CmsCalendarSerialDateOptions.END_TYPE_TIMES) { occurences = entryDate.getOccurences(); } resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_OCCURENCES, String.valueOf(occurences)); // set the end type radio buttons resolver.addMacro(MACRO_PREFIX_PARAMVALUE + PARAM_ENDTYPE + "." + entryDate.getSerialEndType(), ATTR_CHECKED); return resolver; }
From source file:joshuatee.wx.ModelInterfaceActivity.java
private String ConvertTimeRuntoTimeString(String run_str, String time_str) { int run_int = Integer.parseInt(run_str); int time_int = Integer.parseInt(time_str); int real_time_gmt = run_int + time_int; TimeZone tz = TimeZone.getDefault(); Date now = new Date(System.currentTimeMillis()); int offsetFromUtc = tz.getOffset(now.getTime()) / 1000; int real_time = real_time_gmt + offsetFromUtc / 60 / 60; int hour_of_day = real_time % 24; String am_pm = ""; if (hour_of_day > 11) { am_pm = "pm"; if (hour_of_day > 12) { hour_of_day = hour_of_day - 12; }/* w w w . j a v a2s. c o m*/ } else { am_pm = "am"; } int day = (int) real_time / 24; if (hour_of_day < 0) { hour_of_day = 12 + hour_of_day; am_pm = "pm"; day--; } Calendar calendar = Calendar.getInstance(); int day_of_week = calendar.get(Calendar.DAY_OF_WEEK); int hour_of_day_local = calendar.get(Calendar.HOUR_OF_DAY); if (run_int >= 0 && run_int < -offsetFromUtc / 60 / 60 && (hour_of_day_local - offsetFromUtc / 60 / 60) >= 24) { day++; } String future_day = ""; switch ((day_of_week + day) % 7) { case Calendar.SUNDAY: future_day = "Sun"; break; case Calendar.MONDAY: future_day = "Mon"; break; case Calendar.TUESDAY: future_day = "Tue"; break; case Calendar.WEDNESDAY: future_day = "Wed"; break; case Calendar.THURSDAY: future_day = "Thu"; break; case Calendar.FRIDAY: future_day = "Fri"; break; case 0: future_day = "Sat"; break; } //return future_day + " "+hour_of_day.toString()+ am_pm; return future_day + " " + Integer.toString(hour_of_day) + am_pm; }
From source file:dbtimetable.DBTimetableMIDletClass.java
private boolean is_weekdays(Calendar the_date) { // MONDAY -> 2 // TUESDAY -> 3 // WEDNESDAY -> 4 // THURSDAY -> 5 // FRIDAY -> 6 if ((the_date.get(Calendar.DAY_OF_WEEK) >= Calendar.MONDAY) && (the_date.get(Calendar.DAY_OF_WEEK) <= Calendar.FRIDAY)) { return true; } else {/* ww w.j a v a 2s . c o m*/ return false; } }
From source file:com.bt.heliniumstudentapp.ScheduleFragment.java
private static GregorianCalendar getDate() { GregorianCalendar date = new GregorianCalendar(HeliniumStudentApp.LOCALE); date.clear();/* ww w .ja v a 2 s . c o m*/ date.set(Calendar.YEAR, new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.YEAR)); //FIXME BAD date.set(Calendar.WEEK_OF_YEAR, scheduleFocus); date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); return date; }
From source file:org.eevolution.form.VCRP.java
public boolean checkResourceTypeAvailability(Timestamp dateTime, MResourceType t) { if (!t.isDateSlot()) { return true; }// w ww .j a v a2s . c o m GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(dateTime.getTime()); boolean retValue = false; switch (gc.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: retValue = t.isOnSunday(); break; case Calendar.MONDAY: retValue = t.isOnMonday(); break; case Calendar.TUESDAY: retValue = t.isOnTuesday(); break; case Calendar.WEDNESDAY: retValue = t.isOnWednesday(); break; case Calendar.THURSDAY: retValue = t.isOnThursday(); break; case Calendar.FRIDAY: retValue = t.isOnFriday(); break; case Calendar.SATURDAY: retValue = t.isOnSaturday(); break; } return retValue; }
From source file:com.adito.boot.Util.java
/** * Get a day of week constant suitable for use with {@link Calendar} * given an english day day. This may be any case and only the first * 3 characters are tested for (i.e. sun, mon, tue, etc ..) * //from w w w . j av a2 s . com * @param text * @return day of week */ public static int getDayOfWeekForText(String text) { text = text.toLowerCase(); if (text.startsWith("sun")) { return Calendar.SUNDAY; } else if (text.startsWith("mon")) { return Calendar.MONDAY; } else if (text.startsWith("tue")) { return Calendar.TUESDAY; } else if (text.startsWith("wed")) { return Calendar.WEDNESDAY; } else if (text.startsWith("thu")) { return Calendar.THURSDAY; } else if (text.startsWith("fri")) { return Calendar.FRIDAY; } else if (text.startsWith("sat")) { return Calendar.SATURDAY; } return 0; }
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.ExamsMapRenderer.java
private void renderExamsForRowOfDays(StringBuilder strBuffer, int week, Integer year1, Integer year2, PageContext pageContext) {//from ww w . jav a2 s. co m for (int slot = 0; slot < daysOfWeek.length; slot++) { ExamsMapSlot examsMapSlot = (ExamsMapSlot) examsMap.getDays().get(week * daysOfWeek.length + slot); String classCSS = "exam_cell_content"; if (examsMapSlot.getDay().get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) { classCSS += "_first"; } if (week == numberOfWeks - 1) { classCSS += "_bottom"; } strBuffer.append("<td ").append("class='").append(classCSS).append("'>"); strBuffer.append(examsMapSlotContentRenderer.renderDayContents( (ExamsMapSlot) examsMap.getDays().get(week * daysOfWeek.length + slot), year1, year2, user, pageContext)); strBuffer.append("</td>"); } }
From source file:com.aimluck.eip.schedule.util.ScheduleUtils.java
/** * ?????????????//from w ww.j a va 2 s .co m * * @param date * @param ptn * @param startDate * @param limitDate * @return */ public static boolean isView(ALDateTimeField date, String ptn, Date startDate, Date limitDate) { int count = 0; boolean result = false; Calendar cal = Calendar.getInstance(); cal.setTime(date.getValue()); // if (ptn.charAt(0) == 'D') { result = true; count = 1; // , } else if (ptn.charAt(0) == 'W') { int dow = cal.get(Calendar.DAY_OF_WEEK); // ?? int dowim = cal.get(Calendar.DAY_OF_WEEK_IN_MONTH); if (ptn.charAt(8) == 'N' || ptn.charAt(8) == 'L' || dowim == Character.getNumericValue(ptn.charAt(8))) { switch (dow) { // case Calendar.SUNDAY: result = ptn.charAt(1) != '0'; break; // case Calendar.MONDAY: result = ptn.charAt(2) != '0'; break; // ? case Calendar.TUESDAY: result = ptn.charAt(3) != '0'; break; // case Calendar.WEDNESDAY: result = ptn.charAt(4) != '0'; break; // case Calendar.THURSDAY: result = ptn.charAt(5) != '0'; break; // case Calendar.FRIDAY: result = ptn.charAt(6) != '0'; break; // case Calendar.SATURDAY: result = ptn.charAt(7) != '0'; break; default: result = false; break; } if (ptn.length() == 9) { count = 8; } else { count = 9; } } // } else if (ptn.charAt(0) == 'M') { int mday; if (ptn.substring(1, 3).equals("XX")) { mday = cal.getActualMaximum(Calendar.DATE); } else { mday = Integer.parseInt(ptn.substring(1, 3)); } result = Integer.parseInt(date.getDay()) == mday; count = 3; } else if (ptn.charAt(0) == 'Y') { int ymonth = Integer.parseInt(ptn.substring(1, 3)); int yday = Integer.parseInt(ptn.substring(3, 5)); int month = Integer.parseInt(date.getMonth()); int day = Integer.parseInt(date.getDay()); if (ymonth == month && yday == day) { result = true; count = 5; } else { result = false; } } else { return true; } if (result) { if (ptn.charAt(count) == 'L') { // ???? if (equalsToDate(startDate, date.getValue(), false) || equalsToDate(limitDate, date.getValue(), false)) { // ??? result = true; } else { // ???????????? result = result && startDate.before(cal.getTime()) && limitDate.after(cal.getTime()); } } } return result; }