List of usage examples for java.util Calendar SUNDAY
int SUNDAY
To view the source code for java.util Calendar SUNDAY.
Click Source Link
From source file:com.glaf.core.web.springmvc.WorkCalendarController.java
/** * //from w w w .j av a 2 s . c o m * * @param request * @param modelMap * @return */ @RequestMapping("/showCalendar") public ModelAndView showCalendar(HttpServletRequest request, ModelMap modelMap) { Calendar cal = Calendar.getInstance(); int month = RequestUtils.getIntParameter(request, "month", cal.get(Calendar.MONTH)); int year = RequestUtils.getIntParameter(request, "year", cal.get(Calendar.YEAR)); cal.set(Calendar.MONTH, month); // cal.set(Calendar.YEAR, year); // cal.setFirstDayOfWeek(Calendar.SUNDAY); cal.set(Calendar.DAY_OF_MONTH, 1); logger.info("month:" + month); int firstIndex = cal.get(Calendar.DAY_OF_WEEK) - 1; // logger.info("firstIndex:" + firstIndex); int maxIndex = cal.getActualMaximum(Calendar.DAY_OF_MONTH);// logger.info("maxIndex:" + maxIndex); int weeks = Calendar.WEEK_OF_MONTH;// cal.set(Calendar.DATE, 1);// 1? if (cal.get(Calendar.DAY_OF_WEEK) == 7) weeks += 1; logger.info("day of week:" + cal.get(Calendar.DAY_OF_WEEK)); logger.info("weeks:" + weeks); String days[] = new String[42]; for (int i = 0; i < 42; i++) { days[i] = ""; } for (int i = 0; i < maxIndex; i++) { days[firstIndex + i] = String.valueOf(i + 1); } List<Integer> list = workCalendarService.getWorkDateList(year, month + 1); if (list == null) { list = new java.util.ArrayList<Integer>(); } request.setAttribute("list", list); request.setAttribute("year", String.valueOf(year)); request.setAttribute("month", String.valueOf(month)); request.setAttribute("weeks", String.valueOf(weeks)); request.setAttribute("days", days); String x_view = ViewProperties.getString("calendar.showCalendar"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/sys/calendar/calendar", modelMap); }
From source file:com.shalzz.attendance.adapter.TimeTablePagerAdapter.java
public void updateDates() { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext); boolean show = sharedPref.getBoolean(mContext.getString(R.string.pref_key_show_weekends), true); int day_offset = 0; Calendar calendar = Calendar.getInstance(); for (int i = 0; i < getCount(); i++) { calendar.setTime(mDate);//from w w w . ja v a 2s . c om calendar.add(Calendar.DATE, -15 + i); if (!show) { calendar.add(Calendar.DATE, day_offset); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) { calendar.add(Calendar.DATE, 1); ++day_offset; } if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { calendar.add(Calendar.DATE, 1); ++day_offset; } } Date date = calendar.getTime(); dates.put(i, date); positions.put(date, i); } }
From source file:org.structr.common.RecurringDateHelper.java
private static int getDayOfWeek(final String shortWeekday) { if (shortWeekday != null && !shortWeekday.equals("")) try {/* w w w . j av a2 s . co m*/ ShortWeekday wd = ShortWeekday.valueOf(shortWeekday); switch (wd) { case Mo: return Calendar.MONDAY; case Di: return Calendar.TUESDAY; case Mi: return Calendar.WEDNESDAY; case Do: return Calendar.THURSDAY; case Fr: return Calendar.FRIDAY; case Sa: return Calendar.SATURDAY; case So: return Calendar.SUNDAY; } } catch (Throwable t) { logger.log(Level.WARNING, "Unable to parse day of week for string {0}", shortWeekday); } return 0; }
From source file:com.binary_machinery.avalonschedule.view.schedule.SchedulePagerAdapter.java
private Calendar getWeekEnd(int position) { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(m_minDate);/*from w ww. j av a 2 s . c o m*/ calendar.add(Calendar.WEEK_OF_MONTH, position); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); calendar.set(Calendar.HOUR, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MILLISECOND, 999); return calendar; }
From source file:org.onebusaway.webapp.actions.where.ScheduleAction.java
public List<String> getShortWeekDays() { List<String> result = new ArrayList<String>(); DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(getLocale()); String shortWeekdays[] = dateFormatSymbols.getShortWeekdays(); Calendar calendar = Calendar.getInstance(getLocale()); int firstDayOfWeek = calendar.getFirstDayOfWeek(); for (int dayOfWeek = firstDayOfWeek; dayOfWeek < shortWeekdays.length; dayOfWeek++) { result.add(shortWeekdays[dayOfWeek]); }/*w w w . ja va 2 s. c o m*/ for (int dayOfWeek = Calendar.SUNDAY; dayOfWeek < firstDayOfWeek; dayOfWeek++) { result.add(shortWeekdays[dayOfWeek]); } return result; }
From source file:org.energy_home.jemma.ah.ebrain.algo.DailyTariff.java
private float[] getSlotDailyTariffProfile(Calendar calendar) { int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if (dayOfWeek != Calendar.SUNDAY && CalendarUtil.isHolyday(calendar)) dayOfWeek = Calendar.SUNDAY; return slotsWeekTariffs[dayOfWeek - 1]; }
From source file:in.suraj.timetableswipe.TYFragment.java
private void init() { rgroup = (RadioGroup) rootView.findViewById(R.id.rbgrp); rbMon = (RadioButton) rootView.findViewById(R.id.rbMon); rbTue = (RadioButton) rootView.findViewById(R.id.rbTue); rbWed = (RadioButton) rootView.findViewById(R.id.rbWed); rbThur = (RadioButton) rootView.findViewById(R.id.rbThur); rbFri = (RadioButton) rootView.findViewById(R.id.rbFri); tvLect1Name = (TextView) rootView.findViewById(R.id.tvLect1Name); tvLect1Prof = (TextView) rootView.findViewById(R.id.tvLect1Prof); tvLect2Name = (TextView) rootView.findViewById(R.id.tvLect2Name); tvLect2Prof = (TextView) rootView.findViewById(R.id.tvLect2Prof); tvLect3Name = (TextView) rootView.findViewById(R.id.tvLect3Name); tvLect3Prof = (TextView) rootView.findViewById(R.id.tvLect3Prof); tvLect4Name = (TextView) rootView.findViewById(R.id.tvLect4Name); tvLect4Prof = (TextView) rootView.findViewById(R.id.tvLect4Prof); tvLect5Name = (TextView) rootView.findViewById(R.id.tvLect5Name); tvLect5Prof = (TextView) rootView.findViewById(R.id.tvLect5Prof); Calendar c = Calendar.getInstance(); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if (Calendar.MONDAY == dayOfWeek) { setUpMonday();/*ww w .jav a 2 s .c o m*/ } else if (Calendar.TUESDAY == dayOfWeek) { setUpTuesday(); } else if (Calendar.WEDNESDAY == dayOfWeek) { setUpWednesday(); } else if (Calendar.THURSDAY == dayOfWeek) { setUpThursday(); } else if (Calendar.FRIDAY == dayOfWeek) { setUpFriday(); } else if (Calendar.SATURDAY == dayOfWeek) { } else if (Calendar.SUNDAY == dayOfWeek) { } }
From source file:in.suraj.timetableswipe.SYFragment.java
private void init() { rgroup = (RadioGroup) rootView.findViewById(R.id.rbgrp); rbMon = (RadioButton) rootView.findViewById(R.id.rbMon); rbTue = (RadioButton) rootView.findViewById(R.id.rbTue); rbWed = (RadioButton) rootView.findViewById(R.id.rbWed); rbThur = (RadioButton) rootView.findViewById(R.id.rbThur); rbFri = (RadioButton) rootView.findViewById(R.id.rbFri); tvLect1Name = (TextView) rootView.findViewById(R.id.tvLect1Name); tvLect1Prof = (TextView) rootView.findViewById(R.id.tvLect1Prof); tvLect2Name = (TextView) rootView.findViewById(R.id.tvLect2Name); tvLect2Prof = (TextView) rootView.findViewById(R.id.tvLect2Prof); tvLect3Name = (TextView) rootView.findViewById(R.id.tvLect3Name); tvLect3Prof = (TextView) rootView.findViewById(R.id.tvLect3Prof); tvLect4Name = (TextView) rootView.findViewById(R.id.tvLect4Name); tvLect4Prof = (TextView) rootView.findViewById(R.id.tvLect4Prof); tvLect5Name = (TextView) rootView.findViewById(R.id.tvLect5Name); tvLect5Prof = (TextView) rootView.findViewById(R.id.tvLect5Prof); Calendar c = Calendar.getInstance(); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if (Calendar.MONDAY == dayOfWeek) { setUpMonday();/*from w ww . j a v a 2s .c o m*/ } else if (Calendar.TUESDAY == dayOfWeek) { setUpTuesday(); } else if (Calendar.WEDNESDAY == dayOfWeek) { setUpWednesday(); } else if (Calendar.THURSDAY == dayOfWeek) { setUpThursday(); } else if (Calendar.FRIDAY == dayOfWeek) { setUpFriday(); } else if (Calendar.SATURDAY == dayOfWeek) { } else if (Calendar.SUNDAY == dayOfWeek) { } }
From source file:edu.ucsb.nceas.ezid.test.EZIDServiceTest.java
/** Generate a timestamp for use in IDs. */ public static String generateTimeString() { StringBuffer guid = new StringBuffer(); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime);/*w ww .jav a2 s .com*/ guid.append(calendar.get(Calendar.YEAR)); guid.append(calendar.get(Calendar.DAY_OF_YEAR)); guid.append(calendar.get(Calendar.HOUR_OF_DAY)); guid.append(calendar.get(Calendar.MINUTE)); guid.append(calendar.get(Calendar.SECOND)); guid.append(calendar.get(Calendar.MILLISECOND)); double random = Math.random(); guid.append(random); return guid.toString(); }
From source file:org.jasig.schedassist.model.CommonDateOperations.java
/** * Helper method to calculate the first week's end date. * /*from ww w .ja v a 2 s . co m*/ * @param date * @return the number of days from date until the following Sunday */ public static int numberOfDaysUntilSunday(final Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); int result = 7; switch (dayOfWeek) { case Calendar.SUNDAY: result = 7; break; case Calendar.MONDAY: result = 6; break; case Calendar.TUESDAY: result = 5; break; case Calendar.WEDNESDAY: result = 4; break; case Calendar.THURSDAY: result = 3; break; case Calendar.FRIDAY: result = 2; break; case Calendar.SATURDAY: result = 1; break; } return result; }