Java Code Examples for java.util.Calendar.MONDAY

The following are Jave code examples for showing how to use MONDAY of the java.util.Calendar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: LightSIP   File: SIPDate.java   View Source Code Vote up 8 votes
/**
 * Set the wkday member
 * @param w String to set
 * @throws IllegalArgumentException if w is not a valid day.
 */
public void setWkday(String w) throws IllegalArgumentException {
    sipWkDay = w;
    if (sipWkDay.compareToIgnoreCase(MON) == 0) {
        wkday = Calendar.MONDAY;
    } else if (sipWkDay.compareToIgnoreCase(TUE) == 0) {
        wkday = Calendar.TUESDAY;
    } else if (sipWkDay.compareToIgnoreCase(WED) == 0) {
        wkday = Calendar.WEDNESDAY;
    } else if (sipWkDay.compareToIgnoreCase(THU) == 0) {
        wkday = Calendar.THURSDAY;
    } else if (sipWkDay.compareToIgnoreCase(FRI) == 0) {
        wkday = Calendar.FRIDAY;
    } else if (sipWkDay.compareToIgnoreCase(SAT) == 0) {
        wkday = Calendar.SATURDAY;
    } else if (sipWkDay.compareToIgnoreCase(SUN) == 0) {
        wkday = Calendar.SUNDAY;
    } else {
        throw new IllegalArgumentException("Illegal Week day :" + w);
    }
}
 
Example 2
Project: ChronoBike   File: OpenCalendar.java   View Source Code Vote up 7 votes
private int getDayOfWeeekId(String csDayValue)
{
	csDayValue = csDayValue.toUpperCase();
	if(csDayValue.startsWith("MON"))
		return Calendar.MONDAY;
	else if(csDayValue.startsWith("TUE"))
		return Calendar.TUESDAY;
	else if(csDayValue.startsWith("WED"))
		return Calendar.WEDNESDAY;
	else if(csDayValue.startsWith("THU"))
		return Calendar.THURSDAY;
	else if(csDayValue.startsWith("FRI"))
		return Calendar.FRIDAY;
	else if(csDayValue.startsWith("SAT"))
		return Calendar.SATURDAY;
	return Calendar.SUNDAY;
}
 
Example 3
Project: DateScroller   File: DateScrollerUitls.java   View Source Code Vote up 7 votes
public static String formateDay(Context context,int dayOfWeak){
    switch (dayOfWeak){
        case Calendar.SUNDAY:
        default:
            return  context.getString(R.string.datescroller_sunday);
        case Calendar.MONDAY:
            return context.getString(R.string.datescroller_monday);
        case Calendar.TUESDAY:
            return context.getString(R.string.datescroller_tuseday);
        case Calendar.WEDNESDAY:
            return context.getString(R.string.datescroller_wednesday);
        case Calendar.THURSDAY:
            return context.getString(R.string.datescroller_thursday);
        case Calendar.FRIDAY:
            return context.getString(R.string.datescroller_friday);
        case Calendar.SATURDAY:
            return context.getString(R.string.datescroller_saturday);
    }
}
 
Example 4
Project: unitimes   File: MeetingCountingDuration.java   View Source Code Vote up 7 votes
protected int nbrMeetings(DatePattern datePattern, int dayCode) {
	if (datePattern == null) return 0;
	Calendar cal = Calendar.getInstance(Locale.US);
	cal.setTime(datePattern.getStartDate()); cal.setLenient(true);
       String pattern = datePattern.getPattern();
       int ret = 0;
       for (int idx = 0; idx < pattern.length(); idx++) {
       	if (pattern.charAt(idx) == '1') {
       		boolean offered = false;
       		switch (cal.get(Calendar.DAY_OF_WEEK)) {
       			case Calendar.MONDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_MON]) != 0); break;
       			case Calendar.TUESDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_TUE]) != 0); break;
       			case Calendar.WEDNESDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_WED]) != 0); break;
       			case Calendar.THURSDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_THU]) != 0); break;
       			case Calendar.FRIDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_FRI]) != 0); break;
       			case Calendar.SATURDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_SAT]) != 0); break;
       			case Calendar.SUNDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_SUN]) != 0); break;
       		}
       		if (offered) ret++;
       	}
       	cal.add(Calendar.DAY_OF_YEAR, 1);
       }
       return ret;
}
 
Example 5
Project: unitimes   File: Constants.java   View Source Code Vote up 7 votes
public static int getDayOfWeek(Date date) {
  	Calendar c = Calendar.getInstance(Locale.US);
  	c.setTime(date);
switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.MONDAY:
	return DAY_MON;
case Calendar.TUESDAY:
	return DAY_TUE;
case Calendar.WEDNESDAY:
	return DAY_WED;
case Calendar.THURSDAY:
	return DAY_THU;
case Calendar.FRIDAY:
	return DAY_FRI;
case Calendar.SATURDAY:
	return DAY_SAT;
case Calendar.SUNDAY:
	return DAY_SUN;
default:
	return DAY_MON;
}
  }
 
Example 6
Project: broadlink-java-api   File: DiscoveryPacket.java   View Source Code Vote up 7 votes
private static int dayOfWeekConv(int fieldVal) {
    switch (fieldVal) {
    case Calendar.SUNDAY:
        return 6;
    case Calendar.MONDAY:
        return 0;
    case Calendar.TUESDAY:
        return 1;
    case Calendar.WEDNESDAY:
        return 2;
    case Calendar.THURSDAY:
        return 3;
    case Calendar.FRIDAY:
        return 4;
    case Calendar.SATURDAY:
        return 5;
    }
    return -1;
}
 
Example 7
Project: unitimes   File: ClassesAction.java   View Source Code Vote up 7 votes
public int getDaysCode(Set meetings) {
    int daysCode = 0;
    for (Iterator i=meetings.iterator();i.hasNext();) {
        Meeting meeting = (Meeting)i.next();
        Calendar date = Calendar.getInstance(Locale.US);
        date.setTime(meeting.getMeetingDate());
        switch (date.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.MONDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_MON]; break;
        case Calendar.TUESDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_TUE]; break;
        case Calendar.WEDNESDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_WED]; break;
        case Calendar.THURSDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_THU]; break;
        case Calendar.FRIDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_FRI]; break;
        case Calendar.SATURDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_SAT]; break;
        case Calendar.SUNDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_SUN]; break;
        }
    }
    return daysCode;
}
 
Example 8
Project: sample-bluetooth-le-gattserver   File: TimeProfile.java   View Source Code Vote up 7 votes
/**
 * Convert a {@link Calendar} weekday value to the corresponding
 * Bluetooth weekday code.
 */
private static byte getDayOfWeekCode(int dayOfWeek) {
    switch (dayOfWeek) {
        case Calendar.MONDAY:
            return DAY_MONDAY;
        case Calendar.TUESDAY:
            return DAY_TUESDAY;
        case Calendar.WEDNESDAY:
            return DAY_WEDNESDAY;
        case Calendar.THURSDAY:
            return DAY_THURSDAY;
        case Calendar.FRIDAY:
            return DAY_FRIDAY;
        case Calendar.SATURDAY:
            return DAY_SATURDAY;
        case Calendar.SUNDAY:
            return DAY_SUNDAY;
        default:
            return DAY_UNKNOWN;
    }
}
 
Example 9
Project: unitimes   File: MakeAssignmentsForClassEvents.java   View Source Code Vote up 7 votes
public int getDaysCode(Event event) {
    int daysCode = 0;
    for (Iterator i=event.getMeetings().iterator();i.hasNext();) {
        Meeting meeting = (Meeting)i.next();
        Calendar date = Calendar.getInstance(Locale.US);
        date.setTime(meeting.getMeetingDate());
        switch (date.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.MONDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_MON]; break;
        case Calendar.TUESDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_TUE]; break;
        case Calendar.WEDNESDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_WED]; break;
        case Calendar.THURSDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_THU]; break;
        case Calendar.FRIDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_FRI]; break;
        case Calendar.SATURDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_SAT]; break;
        case Calendar.SUNDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_SUN]; break;
        }
    }
    return daysCode;
}
 
Example 10
Project: MonthView   File: MonthView.java   View Source Code Vote up 7 votes
private void updateWeekdayArray(int day) {
    Locale chineseLocale = new Locale("zh");
    Locale currentLocale = Locale.getDefault();
    boolean isChineseUser = currentLocale.getLanguage().equals(chineseLocale.getLanguage());
    Resources resources = getContext().getResources();
    
    if (isChineseUser) {
        if (day == Calendar.MONDAY) {
            mWeekdayName = resources.getStringArray(R.array.monday_first_chinese_weekday_name);
        } else if (day == Calendar.SUNDAY) {
            mWeekdayName = resources.getStringArray(R.array.sunday_first_chinese_weekday_name);
        }
    } else {
        if (day == Calendar.MONDAY) {
            mWeekdayName = resources.getStringArray(R.array.monday_first_english_weekday_name);
        } else if (day == Calendar.SUNDAY) {
            mWeekdayName = resources.getStringArray(R.array.sunday_first_english_weekday_name);
        }
    }
}
 
Example 11
Project: AmenEye   File: DateUtil.java   View Source Code Vote up 7 votes
public static String getWeek(Calendar calendar) {
    String[] week = AmenEyeApplication.getContext().getResources().getStringArray(R.array.week_array);
    int day = calendar.get(Calendar.DAY_OF_WEEK);
    switch (day) {
        case Calendar.MONDAY:
            return week[0];
        case Calendar.TUESDAY:
            return week[1];
        case Calendar.WEDNESDAY:
            return week[2];
        case Calendar.THURSDAY:
            return week[3];
        case Calendar.FRIDAY:
            return week[4];
        case Calendar.SATURDAY:
            return week[5];
        case Calendar.SUNDAY:
            return week[6];
        default:
            return null;
    }
}
 
Example 12
Project: unitimes   File: ClassInfoConnector.java   View Source Code Vote up 6 votes
protected static Date firstDate(DatePattern dp, int dayCode) {
   	if (dp == null) return null;
   	BitSet weekCode = dp.getPatternBitSet();
   	if (weekCode.isEmpty()) return null;
   	Calendar cal = Calendar.getInstance(Locale.US); cal.setLenient(true);
   	Date dpFirstDate = DateUtils.getDate(1, dp.getSession().getPatternStartMonth(), dp.getSession().getSessionStartYear());
   	cal.setTime(dpFirstDate);
   	int idx = weekCode.nextSetBit(0);
   	cal.add(Calendar.DAY_OF_YEAR, idx);
   	while (idx < weekCode.size()) {
   		if (weekCode.get(idx)) {
       		int dow = cal.get(Calendar.DAY_OF_WEEK);
       		switch (dow) {
       		case Calendar.MONDAY:
       			if ((dayCode & DayCode.MON.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.TUESDAY:
       			if ((dayCode & DayCode.TUE.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.WEDNESDAY:
       			if ((dayCode & DayCode.WED.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.THURSDAY:
       			if ((dayCode & DayCode.THU.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.FRIDAY:
       			if ((dayCode & DayCode.FRI.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.SATURDAY:
       			if ((dayCode & DayCode.SAT.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.SUNDAY:
       			if ((dayCode & DayCode.SUN.getCode()) != 0) return cal.getTime();
       			break;
       		}
       	}
   		cal.add(Calendar.DAY_OF_YEAR, 1); idx++;
   	}
   	return null;
}
 
Example 13
Project: SmartMath   File: MFPDateTime.java   View Source Code Vote up 6 votes
public static DataClass getDayOfWeek(LinkedList<DataClass> listParams) throws JFCALCExpErrException {
    if (listParams.size() != 1)   {
        throw new JFCALCExpErrException(ERRORTYPES.ERROR_INCORRECT_NUM_OF_PARAMETER);
    }
    DataClass datumTS = new DataClass();
    datumTS.copyTypeValueDeep(listParams.removeLast());
    datumTS.changeDataType(DATATYPES.DATUM_INTEGER);
    long lTS = datumTS.getDataValue().longValue();
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(lTS);
    int nReturn = cal.get(Calendar.DAY_OF_WEEK);
    int nDayOfWeek = 0;
    switch (nReturn) {
        case (Calendar.SUNDAY): {
            nDayOfWeek = 0;
            break;
        } case (Calendar.MONDAY): {
            nDayOfWeek = 1;
            break;
        } case (Calendar.TUESDAY): {
            nDayOfWeek = 2;
            break;
        } case (Calendar.WEDNESDAY): {
            nDayOfWeek = 3;
            break;
        } case (Calendar.THURSDAY): {
            nDayOfWeek = 4;
            break;
        } case (Calendar.FRIDAY): {
            nDayOfWeek = 5;
            break;
        } case (Calendar.SATURDAY): {
            nDayOfWeek = 6;
            break;
        }
    }
    return new DataClass(DATATYPES.DATUM_INTEGER, new MFPNumeric(nDayOfWeek));
}
 
Example 14
Project: jdk8u-jdk   File: Bug4527203.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
    Calendar huCalendar = Calendar.getInstance(new Locale("hu","HU"));
    int hufirstDayOfWeek = huCalendar.getFirstDayOfWeek();
    if (hufirstDayOfWeek != Calendar.MONDAY) {
        throw new RuntimeException();
    }

    Calendar ukCalendar = Calendar.getInstance(new Locale("uk","UA"));
    int ukfirstDayOfWeek = ukCalendar.getFirstDayOfWeek();
    if (ukfirstDayOfWeek != Calendar.MONDAY) {
        throw new RuntimeException();
    }

}
 
Example 15
Project: Expert-Android-Programming   File: PlaceDetailActivity.java   View Source Code Vote up 6 votes
private void setToday() {
    Calendar calendar = Calendar.getInstance();
    int date = calendar.get(Calendar.DAY_OF_WEEK);

    switch (date) {
        case Calendar.MONDAY:
            dayMonday.setSelected(true);
            break;
        case Calendar.TUESDAY:
            dayTuesday.setSelected(true);
            break;
        case Calendar.WEDNESDAY:
            dayWednesday.setSelected(true);
            break;
        case Calendar.THURSDAY:
            dayThursday.setSelected(true);
            break;
        case Calendar.FRIDAY:
            dayFriday.setSelected(true);
            break;
        case Calendar.SATURDAY:
            daySaturday.setSelected(true);
            break;
        case Calendar.SUNDAY:
            daySunday.setSelected(true);
            break;
    }

}
 
Example 16
Project: unitimes   File: MeetingCountingDuration.java   View Source Code Vote up 6 votes
@Override
public List<Date> getDates(int minutes, DatePattern datePattern, int dayCode, int minutesPerMeeting) {
	List<Date> ret = new ArrayList<Date>();
	if (datePattern == null) return ret;
	Calendar cal = Calendar.getInstance(Locale.US);
	cal.setTime(datePattern.getStartDate()); cal.setLenient(true);
       EventDateMapping.Class2EventDateMap class2eventDates = EventDateMapping.getMapping(datePattern.getSession().getUniqueId());
       String pattern = datePattern.getPattern();
       Integer max = getMaxMeetings(minutes, minutesPerMeeting);
       for (int idx = 0; idx < pattern.length(); idx++) {
       	if (pattern.charAt(idx) == '1') {
       		boolean offered = false;
       		switch (cal.get(Calendar.DAY_OF_WEEK)) {
       			case Calendar.MONDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_MON]) != 0); break;
       			case Calendar.TUESDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_TUE]) != 0); break;
       			case Calendar.WEDNESDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_WED]) != 0); break;
       			case Calendar.THURSDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_THU]) != 0); break;
       			case Calendar.FRIDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_FRI]) != 0); break;
       			case Calendar.SATURDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_SAT]) != 0); break;
       			case Calendar.SUNDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_SUN]) != 0); break;
       		}
       		if (offered) ret.add(class2eventDates.getEventDate(cal.getTime()));
       	}
       	cal.add(Calendar.DAY_OF_YEAR, 1);
       	if (max != null && ret.size() >= max) break;
       }
	return ret;
}
 
Example 17
Project: Keep-HODLing   File: BuyScheduler.java   View Source Code Vote up 5 votes
private static long getFirstTrigger(Context context) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    String period = sharedPref.getString("preference_frequency", "");
    Calendar calendar = Calendar.getInstance();

    long lastBuyTime = new Persistence(context).getLastBuyTime();

    if (lastBuyTime > 0) {
        calendar.setTimeInMillis(lastBuyTime);
        switch (period) {
            case "hourly":
                calendar.add(Calendar.HOUR, 1);
                break;
            case "daily":
                calendar.add(Calendar.DATE, 1);
                break;
            case "monthly":
                calendar.add(Calendar.MONTH, 1);
                break;
            case "weekly":
                calendar.add(Calendar.DATE, 7);
                break;
        }
    }
    else {
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);

        switch (period) {
            case "hourly":
                calendar.add(Calendar.HOUR, 1);
                break;
            case "daily":
            case "monthly":
                calendar.set(Calendar.HOUR, 12);
                break;
            case "weekly":
                calendar.set(Calendar.HOUR, 12);
                while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY)
                    calendar.add(Calendar.DATE, 1);
                break;
        }
    }

    return calendar.getTimeInMillis();
}
 
Example 18
Project: School1-Android   File: DashboardAdapter.java   View Source Code Vote up 5 votes
public DashboardAdapter(Context context) {
    Calendar calendar = Calendar.getInstance();
    int today = calendar.get(Calendar.DAY_OF_WEEK);

    // Today is default
    rowItems.add(new Section(context.getString(R.string.section_title_today), getSectionDate(calendar)));
    calendar.add(Calendar.DAY_OF_YEAR, 1);

    if (today >= Calendar.MONDAY && today <= Calendar.WEDNESDAY) {
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        rowItems.add(new Section(context.getString(R.string.section_title_this_week), getSectionDate(calendar)));
    } else if (today == Calendar.THURSDAY) {
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
    } else if (today == Calendar.FRIDAY)
        rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
    else if (today == Calendar.SATURDAY)
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));

    calendar = Calendar.getInstance();
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

    if (calendar.getFirstDayOfWeek() != Calendar.SUNDAY || today != Calendar.SUNDAY)
        calendar.add(Calendar.WEEK_OF_YEAR, 1);

    rowItems.add(new Section(context.getString(R.string.section_title_next_week), getSectionDate(calendar)));

    // TODO: Holiday and interval sections (between two holidays, to give a clearer overview over whats happening in the long run)
    calendar.add(Calendar.WEEK_OF_YEAR, 1);
    rowItems.add(new Section("Until the end of the universe", getSectionDate(calendar)));

    // TODO: Listen on login
    UserInfo userInfo = FirebaseAuth.getInstance().getCurrentUser();
    if (userInfo != null) {
        DocumentReference userReference = FirebaseFirestore.getInstance()
                .collection("users")
                .document(userInfo.getUid());

        userReference.collection("groups")
                .addSnapshotListener(this);
        userReference.collection("items")
                .addSnapshotListener(new GroupItemsChangeListener(FirebaseAuth.getInstance().getCurrentUser().getUid()));
    }
}
 
Example 19
Project: TIIEHenry-Android-SDK   File: DateUtils.java   View Source Code Vote up 5 votes
/**
 * 获取某天是星期几
 *
 * @param date
 * @return
 */
public static String getMonthDayWeek(Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    int year = c.get(Calendar.YEAR);    //获取年
    int month = c.get(Calendar.MONTH) + 1;   //获取月份,0表示1月份
    int day = c.get(Calendar.DAY_OF_MONTH);    //获取当前天数
    int week = c.get(Calendar.DAY_OF_WEEK);

    String weekStr = null;

    switch (week) {

        case Calendar.SUNDAY:
            weekStr = "周日";
            break;

        case Calendar.MONDAY:
            weekStr = "周一";
            break;

        case Calendar.TUESDAY:
            weekStr = "周二";
            break;

        case Calendar.WEDNESDAY:
            weekStr = "周三";
            break;

        case Calendar.THURSDAY:
            weekStr = "周四";
            break;

        case Calendar.FRIDAY:
            weekStr = "周五";
            break;

        case Calendar.SATURDAY:
            weekStr = "周六";
            break;
    }

    return month + "月" + day + "日" + "(" + weekStr + ")";
}
 
Example 20
Project: unitimes   File: TimetableGridSolutionHelper.java   View Source Code Vote up 5 votes
protected static void createMeetingCells(TimetableGridModel model, Session session, TimetableGridContext context, Collection<TimeBlock> times, String room) {
if (times == null) return;
int sessionYear = session.getSessionStartYear();
      int firstDOY = session.getDayOfYear(1, session.getPatternStartMonth());
      int lastDOY = session.getDayOfYear(0, session.getPatternEndMonth() + 1);
      Calendar c = Calendar.getInstance(Locale.US);
      Formats.Format<Date> df = Formats.getDateFormat(Formats.Pattern.DATE_EVENT_SHORT);
for (TimeBlock time: times) {
	if (time.getEndTime().before(context.getSessionStartDate()) || time.getStartTime().after(context.getSessionEndDate())) continue;
          int dayCode = 0;
          c.setTime(time.getStartTime());
          int m = c.get(Calendar.MONTH);
          int d = c.get(Calendar.DAY_OF_MONTH);
          if (c.get(Calendar.YEAR)<sessionYear) m-=(12 * (sessionYear - c.get(Calendar.YEAR)));
          if (c.get(Calendar.YEAR)>sessionYear) m+=(12 * (c.get(Calendar.YEAR) - sessionYear));
          BitSet weekCode = new BitSet(lastDOY - firstDOY);
          int offset = session.getDayOfYear(d,m) - firstDOY;
          weekCode.set(offset);
          switch (c.get(Calendar.DAY_OF_WEEK)) {
              case Calendar.MONDAY    : dayCode = Constants.DAY_CODES[Constants.DAY_MON]; break;
              case Calendar.TUESDAY   : dayCode = Constants.DAY_CODES[Constants.DAY_TUE]; break;
              case Calendar.WEDNESDAY : dayCode = Constants.DAY_CODES[Constants.DAY_WED]; break;
              case Calendar.THURSDAY  : dayCode = Constants.DAY_CODES[Constants.DAY_THU]; break;
              case Calendar.FRIDAY    : dayCode = Constants.DAY_CODES[Constants.DAY_FRI]; break;
              case Calendar.SATURDAY  : dayCode = Constants.DAY_CODES[Constants.DAY_SAT]; break;
              case Calendar.SUNDAY    : dayCode = Constants.DAY_CODES[Constants.DAY_SUN]; break;
          }
          int startSlot = (c.get(Calendar.HOUR_OF_DAY)*60 + c.get(Calendar.MINUTE) - Constants.FIRST_SLOT_TIME_MIN) / Constants.SLOT_LENGTH_MIN;
          c.setTime(time.getEndTime());
          int endSlot = (c.get(Calendar.HOUR_OF_DAY)*60 + c.get(Calendar.MINUTE) - Constants.FIRST_SLOT_TIME_MIN) / Constants.SLOT_LENGTH_MIN;
          int length = endSlot - startSlot;
          if (length<=0) continue;
          TimeLocation timeLocation = new TimeLocation(dayCode, startSlot, length, 0, 0, null, df.format(time.getStartTime()), weekCode, 0);
  		TimetableGridCell cell = null;
  		for (Enumeration<Integer> f=timeLocation.getStartSlots();f.hasMoreElements();) {
  			int slot = f.nextElement();
  			int idx = (7 + slot/Constants.SLOTS_PER_DAY - context.getWeekOffset()) % 7;
  			if (context.getFirstDay()>=0 && !timeLocation.getWeekCode().get(context.getFirstDay() + idx)) continue;
  			if (cell == null) {
  				cell = new TimetableGridCell();
  				cell.setType(TimetableGridCell.Type.Event);
  				cell.setId(time.getEventId());
  				cell.setDay(slot / Constants.SLOTS_PER_DAY);
  				cell.setSlot(slot % Constants.SLOTS_PER_DAY);
  				cell.addRoom(room);
  				cell.addName(time.getEventName());
  				cell.setProperty(Property.EventType, time.getEventType());
  				cell.setBackground(sBgColorNotAvailable);
  				cell.setLength(length);
  				cell.setTime(Constants.toTime(Constants.SLOT_LENGTH_MIN * startSlot + Constants.FIRST_SLOT_TIME_MIN) + " - " + Constants.toTime(Constants.SLOT_LENGTH_MIN  * endSlot + Constants.FIRST_SLOT_TIME_MIN));
  				cell.setDate(df.format(time.getStartTime()));
  				cell.setWeekCode(pattern2string(weekCode));
  			} else {
  				cell = new TimetableGridCell(cell, slot / Constants.SLOTS_PER_DAY, null);
  			}
  			model.addCell(cell);
  		}
}
  }