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:org.kuali.student.r2.core.scheduling.util.SchedulingServiceUtil.java
public static List<Integer> weekdaysString2WeekdaysList(String weekdaysString) { List<Integer> result = new ArrayList<Integer>(); if (StringUtils.isNotBlank(weekdaysString)) { checkStringForDayCode(SchedulingServiceConstants.MONDAY_TIMESLOT_DAY_CODE, Calendar.MONDAY, result, weekdaysString);//from www .java2 s . co m checkStringForDayCode(SchedulingServiceConstants.TUESDAY_TIMESLOT_DAY_CODE, Calendar.TUESDAY, result, weekdaysString); checkStringForDayCode(SchedulingServiceConstants.WEDNESDAY_TIMESLOT_DAY_CODE, Calendar.WEDNESDAY, result, weekdaysString); checkStringForDayCode(SchedulingServiceConstants.THURSDAY_TIMESLOT_DAY_CODE, Calendar.THURSDAY, result, weekdaysString); checkStringForDayCode(SchedulingServiceConstants.FRIDAY_TIMESLOT_DAY_CODE, Calendar.FRIDAY, result, weekdaysString); checkStringForDayCode(SchedulingServiceConstants.SATURDAY_TIMESLOT_DAY_CODE, Calendar.SATURDAY, result, weekdaysString); checkStringForDayCode(SchedulingServiceConstants.SUNDAY_TIMESLOT_DAY_CODE, Calendar.SUNDAY, result, weekdaysString); } return result; }
From source file:de.micmun.android.workdaystarget.DayCalculator.java
/** * Returns the number of days between today and target, skipped days in * appliance of checkedDays.// w ww. jav a 2s . c om * * @param t Date of the target, to which to calculate the working days. * @param checkedDays Array with boolean flags, which says if a weekday should count * or not. * @return days to target. * @throws JSONException if an error occurs while getting the holidays from web service. */ public int getDaysLeft(Date t, boolean[] checkedDays) throws JSONException { // sets target time at midnight target.setTime(t); setMidnight(target); int sign = 1; if (target.getTimeInMillis() < today.getTimeInMillis()) { Calendar tmp = Calendar.getInstance(); tmp.setTimeInMillis(target.getTimeInMillis()); target.setTimeInMillis(today.getTimeInMillis()); today.setTimeInMillis(tmp.getTimeInMillis()); sign = -1; // negative days in the past } // Holidays ArrayList<Date> holidays = getHolidays(); // current time Calendar curr = Calendar.getInstance(); curr.setTime(today.getTime()); int count = 0; while (curr.getTimeInMillis() != target.getTimeInMillis()) { curr.add(Calendar.DAY_OF_MONTH, 1); int dayOfWeek = curr.get(Calendar.DAY_OF_WEEK); if (!checkedDays[POS_HOLIDAY] && holidays.contains(curr.getTime())) { continue; } else if (!checkedDays[POS_SUNDAY] && dayOfWeek == Calendar.SUNDAY) { continue; } else if (dayOfWeek != Calendar.SUNDAY && !checkedDays[dayOfWeek - Calendar.MONDAY]) { continue; } count++; } count *= sign; // if target is in the past, sign == -1 return count; }
From source file:org.sakaiproject.util.CalendarUtil.java
void initDates() { Calendar calendarSunday = Calendar.getInstance(); Calendar calendarMonday = Calendar.getInstance(); Calendar calendarTuesday = Calendar.getInstance(); Calendar calendarWednesday = Calendar.getInstance(); Calendar calendarThursday = Calendar.getInstance(); Calendar calendarFriday = Calendar.getInstance(); Calendar calendarSaturday = Calendar.getInstance(); calendarSunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); calendarMonday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendarTuesday.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); calendarWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); calendarThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); calendarFriday.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); calendarSaturday.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); dateSunday = calendarSunday.getTime(); dateMonday = calendarMonday.getTime(); dateTuesday = calendarTuesday.getTime(); dateWednesday = calendarWednesday.getTime(); dateThursday = calendarThursday.getTime(); dateFriday = calendarFriday.getTime(); dateSaturday = calendarSaturday.getTime(); Calendar calendarJanuary = Calendar.getInstance(); Calendar calendarFebruary = Calendar.getInstance(); Calendar calendarMarch = Calendar.getInstance(); Calendar calendarApril = Calendar.getInstance(); Calendar calendarMay = Calendar.getInstance(); Calendar calendarJune = Calendar.getInstance(); Calendar calendarJuly = Calendar.getInstance(); Calendar calendarAugust = Calendar.getInstance(); Calendar calendarSeptember = Calendar.getInstance(); Calendar calendarOctober = Calendar.getInstance(); Calendar calendarNovember = Calendar.getInstance(); Calendar calendarDecember = Calendar.getInstance(); calendarJanuary.set(Calendar.MONTH, Calendar.JANUARY); calendarFebruary.set(Calendar.MONTH, Calendar.FEBRUARY); calendarMarch.set(Calendar.MONTH, Calendar.MARCH); calendarApril.set(Calendar.MONTH, Calendar.APRIL); calendarMay.set(Calendar.MONTH, Calendar.MAY); calendarJune.set(Calendar.MONTH, Calendar.JUNE); calendarJuly.set(Calendar.MONTH, Calendar.JULY); calendarAugust.set(Calendar.MONTH, Calendar.AUGUST); calendarSeptember.set(Calendar.MONTH, Calendar.SEPTEMBER); calendarOctober.set(Calendar.MONTH, Calendar.OCTOBER); calendarNovember.set(Calendar.MONTH, Calendar.NOVEMBER); calendarDecember.set(Calendar.MONTH, Calendar.DECEMBER); dateJanuary = calendarJanuary.getTime(); dateFebruary = calendarFebruary.getTime(); dateMarch = calendarMarch.getTime(); dateApril = calendarApril.getTime(); dateMay = calendarMay.getTime();/*ww w .ja va 2s .c o m*/ dateJune = calendarJune.getTime(); dateJuly = calendarJuly.getTime(); dateAugust = calendarAugust.getTime(); dateSeptember = calendarSeptember.getTime(); dateOctober = calendarOctober.getTime(); dateNovember = calendarNovember.getTime(); dateDecember = calendarDecember.getTime(); }
From source file:verdandi.model.WeekSelectorModel.java
public String getCurrentMondaySundayRange() { return getDateRep(Calendar.MONDAY) + " - " + getDateRep(Calendar.SUNDAY); }
From source file:org.betaconceptframework.astroboa.portal.utility.CalendarUtils.java
public Calendar[] getCurrentWeekPeriod(TimeZone zone, Locale locale) { Calendar weekStart = GregorianCalendar.getInstance(zone, locale); Calendar weekEnd;/*from w w w . j a va 2s . c o m*/ // find Monday the first week day while (weekStart.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { weekStart.add(Calendar.DAY_OF_MONTH, -1); } // then to find SUNDAY we add 6 days weekEnd = (GregorianCalendar) weekStart.clone(); weekEnd.add(Calendar.DAY_OF_MONTH, 6); setCalendarToStartOfDay(weekStart); setCalendarToEndOfDay(weekEnd); Calendar[] period = { weekStart, weekEnd }; return period; }
From source file:com.clican.pluto.common.calendar.BusinessCalendar.java
/** * Initial method //from w w w . j ava 2 s.c o m */ public void init() { days = new BusinessDay[8]; days[Calendar.SUNDAY] = parseDay(sunday); days[Calendar.MONDAY] = parseDay(monday); days[Calendar.TUESDAY] = parseDay(tuesday); days[Calendar.WEDNESDAY] = parseDay(wednesday); days[Calendar.THURSDAY] = parseDay(thursday); days[Calendar.FRIDAY] = parseDay(friday); days[Calendar.SATURDAY] = parseDay(saturday); holidays = new Holiday[holidayList.size()]; for (int i = 0; i < holidayList.size(); i++) { holidays[i] = parseHoliday(holidayList.get(i)); } }
From source file:com.binary_machinery.avalonschedule.view.schedule.SchedulePagerAdapter.java
private Calendar getWeekBeginning(int position) { Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(m_minDate);/*from w ww. ja va2 s .c o m*/ calendar.add(Calendar.WEEK_OF_MONTH, position); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }
From source file:util.MyUtils.java
public static String getWeekDay(String dob) { // sun - 1, mon (2), tue(3), wed(4), thu (5), fri(6) int day = new Integer(dob.substring(8, dob.length())).intValue(); Calendar cal = Calendar.getInstance(); cal.set(new Integer(getYear(dob)).intValue(), new Integer(getMonthNum(dob)).intValue(), day); int weekDay = cal.get(Calendar.DAY_OF_WEEK); switch (weekDay) { case Calendar.SUNDAY: return "Sunday"; 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"; }//from w w w . j a va2 s .c o m return ""; }
From source file:org.kuali.kfs.module.endow.businessobject.lookup.CalculateProcessDateUsingFrequencyCodeService.java
/** * Method to calculate the next processing week date based on the frequency type * adds the appropriate number of days to the current date * @param dayOfWeek/* www. jav a 2s . c o m*/ * @return next processing date */ protected Date calculateNextWeeklyDate(String dayOfWeekFromFrequencyCode, Date currentDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(currentDate); int daysToAdd = 0; int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); // today's day of the week int maximumDaysInWeek = calendar.getActualMaximum(Calendar.DAY_OF_WEEK); if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.MONDAY)) { if (dayOfWeek < Calendar.MONDAY) daysToAdd = Calendar.MONDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.MONDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.TUESDAY)) { if (dayOfWeek < Calendar.TUESDAY) daysToAdd = Calendar.TUESDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.TUESDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.WEDNESDAY)) { if (dayOfWeek < Calendar.WEDNESDAY) daysToAdd = Calendar.WEDNESDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.WEDNESDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.THURSDAY)) { if (dayOfWeek < Calendar.THURSDAY) daysToAdd = Calendar.THURSDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.THURSDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.FRIDAY)) { if (dayOfWeek < Calendar.FRIDAY) daysToAdd = Calendar.FRIDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.FRIDAY; } calendar.add(Calendar.DAY_OF_MONTH, daysToAdd); return new java.sql.Date(calendar.getTimeInMillis()); }
From source file:com.ocs.dynamo.utils.DateUtils.java
/** * Translates a week code (yyyy-ww) to the starting day (this is taken to be a Monday) of that * week/*from ww w . j av a 2 s . co m*/ * * @param weekCode * @return */ public static Date getStartDateOfWeek(String weekCode) { if (weekCode != null && weekCode.matches(WEEK_CODE_PATTERN)) { int year = getYearFromWeekCode(weekCode); int week = getWeekFromWeekCode(weekCode); Calendar calendar = new GregorianCalendar(DynamoConstants.DEFAULT_LOCALE); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.WEEK_OF_YEAR, week); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); return truncate(calendar).getTime(); } return null; }