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:com.frey.repo.DateUtil.java
/***************************************** * @return interger/*from w w w . j a v a2s . c o m*/ * @ ?? ****************************************/ public static String getYearWeekFirstDay(int yearNum, int weekNum) throws ParseException { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, yearNum); cal.set(Calendar.WEEK_OF_YEAR, weekNum); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); // ???? String tempYear = Integer.toString(yearNum); String tempMonth = Integer.toString(cal.get(Calendar.MONTH) + 1); String tempDay = Integer.toString(cal.get(Calendar.DATE)); String tempDate = tempYear + "-" + tempMonth + "-" + tempDay; return setDateFormat(tempDate, "yyyy-MM-dd"); }
From source file:edu.dlnu.liuwenpeng.EachMintueTransactionSupport.SegmentedTimeline.java
/** * Returns the milliseconds for midnight of the first Monday after * 1-Jan-1900, ignoring daylight savings. * //from ww w . j a v a 2 s . com * @return The milliseconds. * * @since 1.0.7 */ public static long firstMondayAfter1900() { int offset = TimeZone.getDefault().getRawOffset(); TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset); // calculate midnight of first monday after 1/1/1900 relative to // current locale Calendar cal = new GregorianCalendar(z); cal.set(1900, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { cal.add(Calendar.DATE, 1); } //return cal.getTimeInMillis(); // preceding code won't work with JDK 1.3 return cal.getTime().getTime(); }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
private boolean isActiveDate(Calendar cal) { int day = cal.get(Calendar.DAY_OF_WEEK); long timeSinceStart = cal.get(Calendar.HOUR_OF_DAY) * 3600000 + cal.get(Calendar.MINUTE) * 60000 + cal.get(Calendar.SECOND) * 1000; if (day == Calendar.SUNDAY) { return (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd); } else if (day == Calendar.MONDAY) { return (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd); } else if (day == Calendar.TUESDAY) { return (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd); } else if (day == Calendar.WEDNESDAY) { return (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd); } else if (day == Calendar.THURSDAY) { return (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd); } else if (day == Calendar.FRIDAY) { return (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd); } else if (day == Calendar.SATURDAY) { return (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd); } else {/*from w w w .ja v a 2s . c o m*/ return false; } }
From source file:com.bt.heliniumstudentapp.ScheduleFragment.java
@SuppressWarnings("ConstantConditions") @Override//from w ww .j a va 2s. co m public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) { mainContext = (AppCompatActivity) getActivity(); scheduleLayout = inflater.inflate(R.layout.fragment_schedule, viewGroup, false); MainActivity.setToolbarTitle(mainContext, getResources().getString(R.string.schedule), null); weekDaysLV = (ListView) scheduleLayout.findViewById(R.id.lv_weekDays_fs); final boolean restart = PreferenceManager.getDefaultSharedPreferences(mainContext) .getBoolean("forced_restart", false); if (restart) PreferenceManager.getDefaultSharedPreferences(mainContext).edit().putBoolean("forced_restart", false) .apply(); if (restart) { //TODO Database check? MainActivity.setStatusBar(mainContext); scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR); scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null); if (MainActivity.isOnline()) parseData(HeliniumStudentApp.ACTION_ONLINE); else parseData(HeliniumStudentApp.ACTION_OFFLINE); } else if (scheduleJson == null) { final boolean online = MainActivity.isOnline(); scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR); if (online && PreferenceManager.getDefaultSharedPreferences(mainContext) .getBoolean("pref_updates_auto_update", true)) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) new UpdateClass(mainContext, false).execute(); else new UpdateClass(mainContext, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } if (online && (PreferenceManager.getDefaultSharedPreferences(mainContext) .getBoolean("pref_schedule_init", true) || PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null) == null)) { getSchedule(HeliniumStudentApp.DIREC_CURRENT, HeliniumStudentApp.ACTION_INIT_IN); } else if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { MainActivity.setStatusBar(mainContext); scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_0", null); if (online) parseData(HeliniumStudentApp.ACTION_ONLINE); else parseData(HeliniumStudentApp.ACTION_OFFLINE); } } ((SwipeRefreshLayout) scheduleLayout).setColorSchemeResources(MainActivity.accentSecondaryColor, MainActivity.accentPrimaryColor, MainActivity.primaryColor); ((SwipeRefreshLayout) scheduleLayout).setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refresh(); } }); MainActivity.prevIV.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { if (MainActivity.isOnline()) { scheduleFocus--; getSchedule(HeliniumStudentApp.DIREC_BACK, HeliniumStudentApp.ACTION_REFRESH_IN); } else { final int currentWeek = new GregorianCalendar(HeliniumStudentApp.LOCALE) .get(Calendar.WEEK_OF_YEAR); if (scheduleFocus > currentWeek + 1) { scheduleFocus = currentWeek + 1; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_1", null); } else { scheduleFocus = currentWeek; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_0", null); } parseData(HeliniumStudentApp.ACTION_OFFLINE); } } } }); MainActivity.historyIV.setOnClickListener(new OnClickListener() { //FIXME Huge mess private int year; private int monthOfYear; private int dayOfMonth; @Override public void onClick(View v) { if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { if (MainActivity.isOnline()) { MainActivity.setUI(HeliniumStudentApp.VIEW_SCHEDULE, HeliniumStudentApp.ACTION_ONLINE); final AlertDialog.Builder weekpickerDialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(mainContext, MainActivity.themeDialog)); final View view = View.inflate(mainContext, R.layout.dialog_schedule, null); weekpickerDialogBuilder.setView(view); final DatePicker datePicker = (DatePicker) view.findViewById(R.id.np_weekpicker_dw); year = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.YEAR); monthOfYear = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.MONTH); dayOfMonth = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.DAY_OF_MONTH); weekpickerDialogBuilder.setTitle(getString(R.string.go_to)); weekpickerDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final GregorianCalendar date = new GregorianCalendar( HeliniumStudentApp.LOCALE); final GregorianCalendar today = new GregorianCalendar( HeliniumStudentApp.LOCALE); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, monthOfYear); date.set(Calendar.DAY_OF_MONTH, dayOfMonth); date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); today.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); scheduleFocus = (today.get(Calendar.WEEK_OF_YEAR)) - ((int) ((today.getTimeInMillis() / (1000 * 60 * 60 * 24 * 7)) - (date.getTimeInMillis() / (1000 * 60 * 60 * 24 * 7)))); getSchedule(HeliniumStudentApp.DIREC_OTHER, HeliniumStudentApp.ACTION_REFRESH_IN); } }); weekpickerDialogBuilder.setNegativeButton(getString(android.R.string.cancel), null); final AlertDialog weekPickerDialog = weekpickerDialogBuilder.create(); final GregorianCalendar minDate = new GregorianCalendar(HeliniumStudentApp.LOCALE); minDate.set(Calendar.YEAR, 2000); minDate.set(Calendar.WEEK_OF_YEAR, 1); final GregorianCalendar maxDate = new GregorianCalendar(HeliniumStudentApp.LOCALE); maxDate.set(Calendar.YEAR, 2038); maxDate.set(Calendar.WEEK_OF_YEAR, 1); datePicker.init(year, monthOfYear, dayOfMonth, new DatePicker.OnDateChangedListener() { final GregorianCalendar newDate = new GregorianCalendar(HeliniumStudentApp.LOCALE); @Override public void onDateChanged(DatePicker view, int dialogYear, int dialogMonthOfYear, int dialogDayOfMonth) { newDate.set(year, monthOfYear, dayOfMonth); year = dialogYear; monthOfYear = dialogMonthOfYear; dayOfMonth = dialogDayOfMonth; if (minDate != null && minDate.after(newDate)) view.init(minDate.get(Calendar.YEAR), minDate.get(Calendar.MONTH), minDate.get(Calendar.DAY_OF_MONTH), this); else if (maxDate != null && maxDate.before(newDate)) view.init(maxDate.get(Calendar.YEAR), maxDate.get(Calendar.MONTH), maxDate.get(Calendar.DAY_OF_MONTH), this); else view.init(year, monthOfYear, dayOfMonth, this); } }); weekPickerDialog.setCanceledOnTouchOutside(true); weekPickerDialog.show(); weekPickerDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setTextColor(getColor(mainContext, MainActivity.accentSecondaryColor)); weekPickerDialog.getButton(AlertDialog.BUTTON_NEGATIVE) .setTextColor(getColor(mainContext, MainActivity.accentSecondaryColor)); } else { scheduleFocus = new GregorianCalendar(HeliniumStudentApp.LOCALE).get(Calendar.WEEK_OF_YEAR); scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_0", null); parseData(HeliniumStudentApp.ACTION_OFFLINE); } } } }); MainActivity.nextIV.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (checkDatabase() != HeliniumStudentApp.DB_REFRESHING) { if (MainActivity.isOnline()) { scheduleFocus++; getSchedule(HeliniumStudentApp.DIREC_NEXT, HeliniumStudentApp.ACTION_REFRESH_IN); } else { final int currentWeek = new GregorianCalendar(HeliniumStudentApp.LOCALE) .get(Calendar.WEEK_OF_YEAR); if (PreferenceManager.getDefaultSharedPreferences(mainContext).getString("schedule_1", null) != null && scheduleFocus >= currentWeek) { scheduleFocus = currentWeek + 1; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_1", null); } else { scheduleFocus = currentWeek; scheduleJson = PreferenceManager.getDefaultSharedPreferences(mainContext) .getString("schedule_0", null); } parseData(HeliniumStudentApp.ACTION_OFFLINE); } } } }); return scheduleLayout; }
From source file:org.springmodules.validation.util.date.DefaultDateParser.java
private Date simpleParse(String str, Date t) throws DateParseException { for (Iterator iter = this.registrations.keySet().iterator(); iter.hasNext();) { RegexpPredicate predicate = (RegexpPredicate) iter.next(); if (predicate.evaluate(str)) { Object dateParser = this.registrations.get(predicate); if (dateParser instanceof DateParser) { return ((DateParser) dateParser).parse(str); } else if (dateParser instanceof DateModifier) { Calendar calendar = new GregorianCalendar(); calendar.setFirstDayOfWeek(Calendar.MONDAY); if (t == null) { calendar.setTime(new Date()); } else { calendar.setTime(t); }/*from w w w . j a v a 2 s. c o m*/ ((DateModifier) dateParser).modify(calendar, predicate.getGroup1(str)); return calendar.getTime(); } } } return null; }
From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java
/** * Load the page titles to an array. This done so the Title Pager Indicator does not have to construct * them multiple times when changing pages. *///from w ww .j av a2 s. com public void setPageTitles() { mDayPageTitles = new String[mNumberOfTodayInSprint]; mLocale = mRes.getConfiguration().locale; mDateFormat = new SimpleDateFormat("dd.MM.yyyy", mLocale); Calendar date = (Calendar) mStartDate.clone(); for (int i = 0; i < mDayPageTitles.length; i++) { mDayPageTitles[i] = mDateFormat.format(date.getTime()); date.add(Calendar.DATE, 1); } mWeekPageTitles = new String[mNumberOfWeeksInSprint]; int size = mWeekPageTitles.length; for (int i = 0; i < size; i++) { long dateInMillis = mSprintStartDateInMillis + (TimeUnit.MILLISECONDS.convert(i, TimeUnit.DAYS) * 7); date.setTimeInMillis(dateInMillis); date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); mWeekPageTitles[i] = mDateFormat.format(date.getTime()); date.add(Calendar.DATE, 6); mWeekPageTitles[i] += " - " + mDateFormat.format(date.getTime()); } }
From source file:com.jdo.CloudContactUtils.java
public static String getDay() { int d = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); String day = "sun"; switch (d) {//from w ww . j a v a 2 s . c om case Calendar.SUNDAY: day = "sun"; break; case Calendar.MONDAY: day = "mon"; break; case Calendar.TUESDAY: day = "tue"; break; case Calendar.WEDNESDAY: day = "wed"; break; case Calendar.THURSDAY: day = "thu"; break; case Calendar.FRIDAY: day = "fri"; break; case Calendar.SATURDAY: day = "sat"; break; } return day; }
From source file:fr.paris.lutece.plugins.calendar.service.XMLUtils.java
/** * Get the XML of a calendar//from ww w.j a va 2s . c o m * @param local The locale * @param cal The calendar * @param request The request * @return The XML */ public static String getXMLPortletCalendar(Locale local, Calendar cal, HttpServletRequest request) { StringBuffer strXml = new StringBuffer(); String strDay = null; Calendar calendar = new GregorianCalendar(); //Set the calendar in the beginning of the month calendar.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 1); int nDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); //If day of week is sunday: nDayOfWeek = 8 if (nDayOfWeek == 1) { nDayOfWeek = 8; } Calendar calendar2 = new GregorianCalendar(); calendar2.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), calendar.getMaximum(Calendar.DAY_OF_MONTH)); //Beginning of the main xml block: month XmlUtil.beginElement(strXml, TAG_AGENDA_MONTH); String strBaseUrl = AppPathService.getPortalUrl(); UrlItem urlMonth = new UrlItem(strBaseUrl); urlMonth.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); urlMonth.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_DO_SEARCH); urlMonth.addParameter(Constants.PARAMETER_DATE_START, DateUtil.getDateString(calendar.getTime(), local)); urlMonth.addParameter(Constants.PARAMETER_DATE_END, DateUtil.getDateString(calendar2.getTime(), local)); urlMonth.addParameter(Constants.PARAMETER_PERIOD, Constants.PROPERTY_PERIOD_RANGE); String strMonthLabel = Utils.getMonthLabel(Utils.getDate(calendar), local); String strUrlMonth = BEGIN_A_TAG + urlMonth.getUrl() + "\">" + strMonthLabel + END_A_TAG; XmlUtil.addElementHtml(strXml, TAG_AGENDA_MONTH_LABEL, strUrlMonth); //Shortcut tags //Begenning of the xml block: week-shortcuts XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUTS); //Today shortcut XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUT); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTCUT_TODAY, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_PERIOD, Constants.PROPERTY_PERIOD_TODAY); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_START, DateUtil.getDateString(new Date(), local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_END, DateUtil.getDateString(new Date(), local)); XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUT); //Tomorrow shortcut Calendar calTomorrow = new GregorianCalendar(); calTomorrow.add(Calendar.DATE, 1); XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUT); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTCUT_TOMORROW, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_PERIOD, Constants.PROPERTY_PERIOD_RANGE); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_START, DateUtil.getDateString(calTomorrow.getTime(), local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_END, DateUtil.getDateString(calTomorrow.getTime(), local)); XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUT); //Week shortcut Date dateBeginWeek = null; Date dateEndWeek = null; Calendar calendarToday = new GregorianCalendar(); Calendar calendarFirstDay = Calendar.getInstance(); Calendar calendarLastDay = new GregorianCalendar(); calendarFirstDay = calendarToday; calendarFirstDay.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendarLastDay = (GregorianCalendar) calendarFirstDay.clone(); calendarLastDay.add(Calendar.DATE, 6); dateBeginWeek = calendarFirstDay.getTime(); dateEndWeek = calendarLastDay.getTime(); XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUT); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTCUT_WEEK, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_PERIOD, Constants.PROPERTY_PERIOD_WEEK); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_START, DateUtil.getDateString(dateBeginWeek, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_END, DateUtil.getDateString(dateEndWeek, local)); XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUT); //Ending of the xml block: week-shortcuts XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUTS); //Begenning of the xml block: weeks XmlUtil.beginElement(strXml, TAG_AGENDA_WEEKS); //Day label tags XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_MONDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_TUESDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_WEDNESDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_THURSDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_FRIDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_SATURDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_SUNDAY, local)); //Check if the month is ended boolean bDone = false; //check if the month is started boolean bStarted = false; //While the month isn't over... while (!bDone) { //Begenning of the xml block: week XmlUtil.beginElement(strXml, TAG_AGENDA_WEEK); for (int i = 0; i < 7; i++) { if ((((i + 2) != nDayOfWeek) && !bStarted) || bDone) { XmlUtil.beginElement(strXml, TAG_AGENDA_DAY); strDay = BEGIN_TD_TAG + getDayClass(calendar) + ">" + PROPERTY_EMPTY_DAY + END_TD_TAG; XmlUtil.addElementHtml(strXml, TAG_AGENDA_DAY_CODE, strDay); XmlUtil.endElement(strXml, TAG_AGENDA_DAY); continue; } bStarted = true; //put parameters in the url UrlItem urlDay = new UrlItem(strBaseUrl); String strPageId = request != null ? request.getParameter(Constants.PARAMETER_PAGE_ID) : StringUtils.EMPTY; if (StringUtils.isNotBlank(strPageId) && StringUtils.isNumeric(strPageId)) { urlDay.addParameter(Constants.PARAMETER_PAGE_ID, strPageId); } urlDay.addParameter(Constants.PARAMETER_DATE, DateUtil.getDateString(calendar.getTime(), local)); //construct on url based on day String strUrlDay = new String(); strUrlDay = BEGIN_A_TAG + urlDay.getUrl() + "\">" + Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)) + END_A_TAG; XmlUtil.beginElement(strXml, TAG_AGENDA_DAY); Date date = Utils.getDate(Utils.getDate(calendar)); Plugin plugin = PluginService.getPlugin(CalendarPlugin.PLUGIN_NAME); String[] arrayCalendarIds = Utils.getCalendarIds(request); List<Event> listEvent = CalendarSearchService.getInstance().getSearchResults(arrayCalendarIds, null, "", date, date, plugin); if (listEvent.size() != 0) { strDay = BEGIN_TD_TAG + Constants.STYLE_CLASS_SMALLMONTH_DAY + Constants.STYLE_CLASS_SUFFIX_EVENT + ">" + BEGIN_BOLD_TAG + strUrlDay + END_BOLD_TAG + END_TD_TAG; } else { strDay = BEGIN_TD_TAG + getDayClass(calendar) + ">" + Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)) + END_TD_TAG; } XmlUtil.addElementHtml(strXml, TAG_AGENDA_DAY_CODE, strDay); XmlUtil.endElement(strXml, TAG_AGENDA_DAY); int nDay = calendar.get(Calendar.DAY_OF_MONTH); calendar.roll(Calendar.DAY_OF_MONTH, true); int nNewDay = calendar.get(Calendar.DAY_OF_MONTH); if (nNewDay < nDay) { bDone = true; } } //Ending of the xml block: week XmlUtil.endElement(strXml, TAG_AGENDA_WEEK); } //Ending of the xml block: weeks XmlUtil.endElement(strXml, TAG_AGENDA_WEEKS); //Ending of the xml block: month XmlUtil.endElement(strXml, TAG_AGENDA_MONTH); return strXml.toString(); }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
private boolean isActiveDate(Calendar cal, Calendar cal2) { int day = cal.get(Calendar.DAY_OF_WEEK); long timeSinceStart = cal.get(Calendar.HOUR_OF_DAY) * 3600000 + cal.get(Calendar.MINUTE) * 60000 + cal.get(Calendar.SECOND) * 1000; boolean firstDate = false; if (day == Calendar.SUNDAY) { firstDate = (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd); } else if (day == Calendar.MONDAY) { firstDate = (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd); } else if (day == Calendar.TUESDAY) { firstDate = (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd); } else if (day == Calendar.WEDNESDAY) { firstDate = (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd); } else if (day == Calendar.THURSDAY) { firstDate = (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd); } else if (day == Calendar.FRIDAY) { firstDate = (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd); } else if (day == Calendar.SATURDAY) { firstDate = (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd); } else {/* w ww. ja va 2 s .com*/ firstDate = false; } int day2 = cal2.get(Calendar.DAY_OF_WEEK); timeSinceStart = cal2.get(Calendar.HOUR_OF_DAY) * 3600000 + cal2.get(Calendar.MINUTE) * 60000 + cal2.get(Calendar.SECOND) * 1000; boolean secondDate = false; if (day2 == Calendar.SUNDAY) { secondDate = (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd); } else if (day2 == Calendar.MONDAY) { secondDate = (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd); } else if (day2 == Calendar.TUESDAY) { secondDate = (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd); } else if (day2 == Calendar.WEDNESDAY) { secondDate = (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd); } else if (day2 == Calendar.THURSDAY) { secondDate = (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd); } else if (day2 == Calendar.FRIDAY) { secondDate = (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd); } else if (day2 == Calendar.SATURDAY) { secondDate = (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd); } else { secondDate = false; } return (firstDate && secondDate); }
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 . j a va 2 s .c o m return String.valueOf(value); } }