Java Code Examples for java.util.Calendar.WEDNESDAY

The following are Jave code examples for showing how to use WEDNESDAY 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: AmenEye   File: DateUtil.java   View Source Code Vote up 8 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 2
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 3
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 4
Project: buildAPKsApps   File: TimeUtil.java   View Source Code Vote up 7 votes
private static boolean dayIsRepeat(int calendarDow, int repeat) {
  switch (calendarDow) {
    case Calendar.SUNDAY:
      return (1 & repeat) != 0;
    case Calendar.MONDAY:
      return (2 & repeat) != 0;
    case Calendar.TUESDAY:
      return (4 & repeat) != 0;
    case Calendar.WEDNESDAY:
      return (8 & repeat) != 0;
    case Calendar.THURSDAY:
      return (16 & repeat) != 0;
    case Calendar.FRIDAY:
      return (32 & repeat) != 0;
    case Calendar.SATURDAY:
      return (64 & repeat) != 0;
  }
  return true;
}
 
Example 5
Project: Remindy   File: Weekdays.java   View Source Code Vote up 7 votes
public void setDay(int calendarDay, boolean active) {
    switch (calendarDay) {
        case Calendar.MONDAY:
            value.set(0, active);
            break;
        case Calendar.TUESDAY:
            value.set(1, active);
            break;
        case Calendar.WEDNESDAY:
            value.set(2, active);
            break;
        case Calendar.THURSDAY:
            value.set(3, active);
            break;
        case Calendar.FRIDAY:
            value.set(4, active);
            break;
        case Calendar.SATURDAY:
            value.set(5, active);
            break;
        case Calendar.SUNDAY:
            value.set(6, active);
            break;
    }
}
 
Example 6
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 7
Project: SER316-Dresden   File: EventsTableMonthly.java   View Source Code Vote up 6 votes
public Object getValueAt(int row, int col) {
	Event ev = getEventAt(row,col);
	if(ev == null) return "";
	Calendar cal = (Calendar)days[col].get(row);
	String res = "";
	switch(cal.get(Calendar.DAY_OF_WEEK)){
		case Calendar.SUNDAY: res += "SU";
			break;
		case Calendar.MONDAY: res += "MO";
			break;
		case Calendar.TUESDAY: res += "TU";
			break;
		case Calendar.WEDNESDAY: res += "WE";
			break;
		case Calendar.THURSDAY: res += "TH";
			break;
		case Calendar.FRIDAY: res += "FR";
			break;
		case Calendar.SATURDAY: res += "SA";
			break;
		default: res += "??";
	}
	String dOM = cal.get(Calendar.DAY_OF_MONTH) + "";
	switch(cal.get(Calendar.DAY_OF_MONTH)%10){
		case 1: dOM += "st";
			break;
		case 2: dOM += "nd";
			break;
		case 3: dOM += "rd";
			break;
		default:dOM+="th";
	}
	res+= " / " + dOM  + ": ";
	if(ev.getText().equals("")) res+= "EVENT";
	else res += ev.getText();
	return res;       		
}
 
Example 8
Project: bluewatcher   File: TimeService.java   View Source Code Vote up 6 votes
private static byte[] createCurrentTimeValue() {
	byte[] arrayOfByte = new byte[10];
	Calendar localCalendar = Calendar.getInstance();
	int i = localCalendar.get(1);
	arrayOfByte[0] = (byte) (0xFF & i >>> 0);
	arrayOfByte[1] = (byte) (0xFF & i >>> 8);
	arrayOfByte[2] = (byte) (1 + localCalendar.get(2));
	arrayOfByte[3] = (byte) localCalendar.get(5);
	arrayOfByte[4] = (byte) localCalendar.get(11);
	arrayOfByte[5] = (byte) localCalendar.get(12);
	arrayOfByte[6] = (byte) (localCalendar.get(13) + 1);
	switch (localCalendar.get(7)) {
	case Calendar.MONDAY:
		arrayOfByte[7] = 0x01;
		break;
	case Calendar.TUESDAY:
		arrayOfByte[7] = 0x02;
		break;
	case Calendar.WEDNESDAY:
		arrayOfByte[7] = 0x03;
		break;
	case Calendar.THURSDAY:
		arrayOfByte[7] = 0x04;
		break;
	case Calendar.FRIDAY:
		arrayOfByte[7] = 0x05;
		break;
	case Calendar.SATURDAY:
		arrayOfByte[7] = 0x06;
		break;
	case Calendar.SUNDAY:
		arrayOfByte[7] = 0x07;
		break;
	}
	arrayOfByte[8] = (byte) (int) TimeUnit.MILLISECONDS.toSeconds(256 * localCalendar.get(14));
	arrayOfByte[9] = 0;
	return arrayOfByte;
}
 
Example 9
Project: Remindy   File: Weekdays.java   View Source Code Vote up 6 votes
public boolean getDay(int calendarDay) {
    switch (calendarDay) {
        case Calendar.MONDAY:
            return value.get(0);
        case Calendar.TUESDAY:
            return value.get(1);
        case Calendar.WEDNESDAY:
            return value.get(2);
        case Calendar.THURSDAY:
            return value.get(3);
        case Calendar.FRIDAY:
            return value.get(4);
        case Calendar.SATURDAY:
            return value.get(5);
        case Calendar.SUNDAY:
            return value.get(6);
        default:
            throw new InvalidParameterException("Invalid parameter. Must be a Calendar.DAY_OF_WEEK. Given value=" + calendarDay);
    }
}
 
Example 10
Project: CHIP-Android-SDK   File: AlarmFragment.java   View Source Code Vote up 6 votes
void setCurrentClock() {
    ChipRobot robot = ChipRobotFinder.getInstance().getChipRobotConnectedList().get(0);

    Calendar rightNow = Calendar.getInstance();
    final int year = rightNow.get(Calendar.YEAR);
    final int month = rightNow.get(Calendar.MONTH);
    final int day = rightNow.get(Calendar.DATE);
    final int hour = rightNow.get(Calendar.HOUR_OF_DAY);
    final int minute = rightNow.get(Calendar.MINUTE);
    final int seconds = rightNow.get(Calendar.SECOND);
    int dayOfWeek_t = rightNow.get(Calendar.DAY_OF_WEEK);
    switch (dayOfWeek_t) {
        case Calendar.SUNDAY:
            dayOfWeek_t = 0;
            break;
        case Calendar.MONDAY:
            dayOfWeek_t = 1;
            break;
        case Calendar.TUESDAY:
            dayOfWeek_t = 2;
            break;
        case Calendar.WEDNESDAY:
            dayOfWeek_t = 3;
            break;
        case Calendar.THURSDAY:
            dayOfWeek_t = 4;
            break;
        case Calendar.FRIDAY:
            dayOfWeek_t = 5;
            break;
        case Calendar.SATURDAY:
            break;
    }
    final int dayOfWeek = dayOfWeek_t;
    robot.chipSetCurrentClock(year, (byte) (month + 1), (byte) day, (byte) hour, (byte) minute, (byte) seconds, (byte) dayOfWeek);
}
 
Example 11
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 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: unitimes   File: EventLookupBackend.java   View Source Code Vote up 5 votes
public static TreeSet<MeetingInterface> generateUnavailabilityMeetings(Location location, boolean conflict) {
	if (location.getEventAvailability() == null || location.getEventAvailability().length() != Constants.SLOTS_PER_DAY * Constants.DAY_CODES.length) return null;

	TreeSet<MeetingInterface> ret = new TreeSet<MeetingInterface>();
	
	ResourceInterface resource = new ResourceInterface();
	resource.setType(ResourceType.ROOM);
	resource.setId(location.getUniqueId());
	resource.setName(location.getLabel());
	resource.setSize(location.getCapacity());
	resource.setRoomType(location.getRoomTypeLabel());
	resource.setBreakTime(location.getEffectiveBreakTime());
	resource.setMessage(location.getEventMessage());
	resource.setIgnoreRoomCheck(location.isIgnoreRoomCheck());
	resource.setDisplayName(location.getDisplayName());
	
	Calendar calendar = Calendar.getInstance();
       for (int day = 0; day < Constants.DAY_CODES.length; day++)
       	for (int startTime = 0; startTime < Constants.SLOTS_PER_DAY; ) {
       		if (location.getEventAvailability().charAt(day * Constants.SLOTS_PER_DAY + startTime) != '1') { startTime++; continue; }
       		int endTime = startTime + 1;
       		while (endTime < Constants.SLOTS_PER_DAY && location.getEventAvailability().charAt(day * Constants.SLOTS_PER_DAY + endTime) == '1') endTime++;
       		
       		calendar.setTime(location.getSession().getEventBeginDate());
       		int dayOfYear = CalendarUtils.date2dayOfYear(location.getSession().getSessionStartYear(), calendar.getTime());
       		do {
       			int dayOfWeek = -1;
       			switch (calendar.get(Calendar.DAY_OF_WEEK)) {
       			case Calendar.MONDAY: dayOfWeek = Constants.DAY_MON; break;
       			case Calendar.TUESDAY: dayOfWeek = Constants.DAY_TUE; break;
       			case Calendar.WEDNESDAY: dayOfWeek = Constants.DAY_WED; break;
       			case Calendar.THURSDAY: dayOfWeek = Constants.DAY_THU; break;
       			case Calendar.FRIDAY: dayOfWeek = Constants.DAY_FRI; break;
       			case Calendar.SATURDAY: dayOfWeek = Constants.DAY_SAT; break;
       			case Calendar.SUNDAY: dayOfWeek = Constants.DAY_SUN; break;
       			}
       			
       			if (day == dayOfWeek) {
       				MeetingInterface m = null;
       				if (conflict) {
       					MeetingConflictInterface c = new MeetingConflictInterface();
       					c.setName(MESSAGES.unavailableEventDefaultName());
       					c.setType(EventInterface.EventType.Unavailabile);
       					m = c;
       				} else {
       					m = new MeetingInterface();
       				}
               		m.setStartSlot(startTime);
               		m.setEndSlot(endTime);
               		m.setDayOfWeek(dayOfWeek);
               		m.setMeetingDate(calendar.getTime());
               		m.setDayOfYear(dayOfYear);
               		m.setLocation(resource);
               		ret.add(m);
       			}
       			calendar.add(Calendar.DAY_OF_YEAR, 1); dayOfYear++;
       		} while (!calendar.getTime().after(location.getSession().getEventEndDate()));
       		startTime = endTime;
       	}
	return ret;
}
 
Example 14
Project: GitHub   File: MainActivity.java   View Source Code Vote up 5 votes
/**
 * 获得今天是周几
 */
private void printDayOfWeek() {
    //  获取今天是周几,和常量SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY搭配使用
    //  不要用获得的返回值来直接判断周几,例如,返回值为3不代表今天是周三,返回值为3其实是周二
    switch (c.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            Log.i("MainActivityFilter", "今天是周日");
            break;
        case Calendar.MONDAY:
            Log.i("MainActivityFilter", "今天是周一");
            break;
        case Calendar.TUESDAY:
            Log.i("MainActivityFilter", "今天是周二");
            break;
        case Calendar.WEDNESDAY:
            Log.i("MainActivityFilter", "今天是周三");
            break;
        case Calendar.THURSDAY:
            Log.i("MainActivityFilter", "今天是周四");
            break;
        case Calendar.FRIDAY:
            Log.i("MainActivityFilter", "今天是周五");
            break;
        case Calendar.SATURDAY:
            Log.i("MainActivityFilter", "今天是周六");
            break;
        default:
            break;
    }
}
 
Example 15
Project: unitimes   File: EventRoomAvailabilityBackend.java   View Source Code Vote up 5 votes
public static TreeSet<MeetingConflictInterface> generateUnavailabilityMeetings(Location location, List<Integer> dates, int startSlot, int endSlot) {
	if (location.getEventAvailability() == null || location.getEventAvailability().length() != Constants.SLOTS_PER_DAY * Constants.DAY_CODES.length) return null;

	TreeSet<MeetingConflictInterface> ret = new TreeSet<MeetingConflictInterface>();
	
	ResourceInterface resource = new ResourceInterface();
	resource.setType(ResourceType.ROOM);
	resource.setId(location.getUniqueId());
	resource.setName(location.getLabel());
	resource.setSize(location.getCapacity());
	resource.setRoomType(location.getRoomTypeLabel());
	resource.setBreakTime(location.getEffectiveBreakTime());
	resource.setMessage(location.getEventMessage());
	resource.setIgnoreRoomCheck(location.isIgnoreRoomCheck());
	resource.setDisplayName(location.getDisplayName());
	
	Calendar calendar = Calendar.getInstance();
       for (int day = 0; day < Constants.DAY_CODES.length; day++)
       	for (int startTime = 0; startTime < Constants.SLOTS_PER_DAY; ) {
       		if (location.getEventAvailability().charAt(day * Constants.SLOTS_PER_DAY + startTime) != '1') { startTime++; continue; }
       		int endTime = startTime + 1;
       		while (endTime < Constants.SLOTS_PER_DAY && location.getEventAvailability().charAt(day * Constants.SLOTS_PER_DAY + endTime) == '1') endTime++;
       		if (startTime < endSlot && startSlot < endTime) {
           		calendar.setTime(location.getSession().getEventBeginDate());
           		int dayOfYear = CalendarUtils.date2dayOfYear(location.getSession().getSessionStartYear(), calendar.getTime());
           		
           		do {
           			if (dates.contains(dayOfYear)) {
               			int dayOfWeek = -1;
               			switch (calendar.get(Calendar.DAY_OF_WEEK)) {
               			case Calendar.MONDAY: dayOfWeek = Constants.DAY_MON; break;
               			case Calendar.TUESDAY: dayOfWeek = Constants.DAY_TUE; break;
               			case Calendar.WEDNESDAY: dayOfWeek = Constants.DAY_WED; break;
               			case Calendar.THURSDAY: dayOfWeek = Constants.DAY_THU; break;
               			case Calendar.FRIDAY: dayOfWeek = Constants.DAY_FRI; break;
               			case Calendar.SATURDAY: dayOfWeek = Constants.DAY_SAT; break;
               			case Calendar.SUNDAY: dayOfWeek = Constants.DAY_SUN; break;
               			}
               			
               			if (day == dayOfWeek) {
                   			MeetingConflictInterface m = new MeetingConflictInterface();
               				m.setName(MESSAGES.unavailableEventDefaultName());
               				m.setType(EventInterface.EventType.Unavailabile);
                       		m.setStartSlot(startTime);
                       		m.setEndSlot(endTime);
                       		m.setDayOfWeek(dayOfWeek);
                       		m.setMeetingDate(calendar.getTime());
                       		m.setDayOfYear(dayOfYear);
                       		m.setLocation(resource);
                       		ret.add(m);
               			}
           			}
           			calendar.add(Calendar.DAY_OF_YEAR, 1); dayOfYear++;
           		} while (!calendar.getTime().after(location.getSession().getEventEndDate()));        			
       		}
       		startTime = endTime;
       	}
	return ret;
}
 
Example 16
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 17
Project: unitimes   File: CourseOfferingExport.java   View Source Code Vote up 5 votes
protected void exportEvent(Element classElement, Event event, Session session) {
  	if (event == null) return;
  	List<Meeting> meetings = new ArrayList<Meeting>(event.getMeetings());
  	Collections.sort(meetings, new Comparator<Meeting>() {
	@Override
	public int compare(Meeting m1, Meeting m2) {
		if (m1.equals(m2)) return 0;
		int cmp = m1.getMeetingDate().compareTo(m2.getMeetingDate());
		if (cmp != 0) return cmp;
		cmp = m1.getStartPeriod().compareTo(m2.getStartPeriod());
		if (cmp != 0) return cmp;
		Location l1 = (m1.getLocationPermanentId() == null ? null : iMeetingLocations.get(m1.getLocationPermanentId()));
		Location l2 = (m2.getLocationPermanentId() == null ? null : iMeetingLocations.get(m2.getLocationPermanentId()));
		cmp = (l1 == null ? "" : l1.getLabel()).compareTo(l2 == null ? "" : l2.getLabel());
		if (cmp != 0) return cmp;
		return m1.getUniqueId().compareTo(m2.getUniqueId());
	}
});
      for (Meeting meeting: meetings) {
          if (meeting.getStatus() != Meeting.Status.APPROVED) continue;
          Element meetingElement = classElement.addElement("meeting");
          meetingElement.addAttribute("startDate", sDateFormat.format(meeting.getMeetingDate()));
          meetingElement.addAttribute("endDate", sDateFormat.format(meeting.getMeetingDate()));
          meetingElement.addAttribute("startTime", sTimeFormat.format(meeting.getStartTime()));
          meetingElement.addAttribute("endTime", sTimeFormat.format(meeting.getStopTime()));
          Calendar c = Calendar.getInstance(Locale.US); c.setTime(meeting.getMeetingDate());
          switch (c.get(Calendar.DAY_OF_WEEK)) {
              case Calendar.MONDAY : meetingElement.addAttribute("days","M"); break;
              case Calendar.TUESDAY : meetingElement.addAttribute("days","T"); break;
              case Calendar.WEDNESDAY : meetingElement.addAttribute("days","W"); break;
              case Calendar.THURSDAY : meetingElement.addAttribute("days","R"); break;
              case Calendar.FRIDAY : meetingElement.addAttribute("days","F"); break;
              case Calendar.SATURDAY : meetingElement.addAttribute("days","S"); break;
              case Calendar.SUNDAY : meetingElement.addAttribute("days","U"); break;
          }
          Location location = (meeting.getLocationPermanentId() == null ? null : iMeetingLocations.get(meeting.getLocationPermanentId()));
          if (location==null) {
          } else if (location instanceof Room) {
              meetingElement.addAttribute("building", ((Room)location).getBuildingAbbv());
              meetingElement.addAttribute("room", ((Room)location).getRoomNumber());
          } else {
              meetingElement.addAttribute("location", location.getLabel());
          }
      }
  }
 
Example 18
Project: routineKeen   File: HabitTrackerFullTest.java   View Source Code Vote up 5 votes
@Test
public void testHabitSchedule() {

    // Get current day of the week in string form
    String today;
    int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
    switch (day) {
        case Calendar.SUNDAY:   today = "Sun";  break;
        case Calendar.MONDAY:   today = "Mon";  break;
        case Calendar.TUESDAY:  today = "Tue";  break;
        case Calendar.WEDNESDAY:today = "Wed";  break;
        case Calendar.THURSDAY: today = "Thu";  break;
        case Calendar.FRIDAY:   today = "Fri";  break;
        case Calendar.SATURDAY: today = "Sat";  break;
        default:                today = null;   break;
    }

    login();

    // add 2 habits
    solo.assertCurrentActivity("Wrong Activity", UserMenu.class);
    solo.clickOnText("View Habit List");
    clearHabitList();

    addTestHabit(TEST_HABIT_NAME, TEST_HABIT_REASON);
    addTestHabit(TEST_HABIT_NAME2, TEST_HABIT_REASON);
    addTestHabit(TEST_HABIT_NAME3, TEST_HABIT_REASON);

    solo.assertCurrentActivity("Wrong Activity", HabitListActivity.class);
    solo.clickOnText(TEST_HABIT_NAME);
    disableAllDays();
    solo.clickOnButton("Save");

    solo.assertCurrentActivity("Wrong Activity", HabitListActivity.class);
    solo.clickOnText(TEST_HABIT_NAME2);
    disableAllDays();
    solo.clickOnText(today);
    solo.clickOnButton("Save");

    solo.goBack();
    solo.assertCurrentActivity("Wrong Activity", UserMenu.class);
    solo.clickOnText("View Habit Schedule");

    try { TimeUnit.SECONDS.sleep(2); } catch (InterruptedException e) { Log.d(LOG, "wait interrupted"); }
    // check that there are 2 habits in today's schedule
    assertEquals(((ListView)solo.getView("habitSchedule_listView")).getAdapter().getCount(), 2);
}
 
Example 19
Project: minu-poska-android   File: Timetable.java   View Source Code Vote up 5 votes
private int getDayIndexIn(int daysAfterToday, List<Day> dayList) {
    // Calculate today's day of week
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_WEEK, daysAfterToday);
    int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);

    // Match it to a schoolday
    String dayStr = "";
    switch (dayOfWeek) {
        case Calendar.MONDAY:
            dayStr = "e";
            break;
        case Calendar.TUESDAY:
            dayStr = "t";
            break;
        case Calendar.WEDNESDAY:
            dayStr = "k";
            break;
        case Calendar.THURSDAY:
            dayStr = "n";
            break;
        case Calendar.FRIDAY:
            dayStr = "r";
            break;
        case Calendar.SATURDAY:
            dayStr = "l";
            break;
        case Calendar.SUNDAY:
            dayStr = "p";
            break;
    }
    for (int i = 0; i < dayList.size(); i++)
        if (dayList.get(i).getName().toLowerCase().startsWith(dayStr))
            return i;
    return -1;
}
 
Example 20
Project: DMS   File: ApplyDataUtil.java   View Source Code Vote up 4 votes
public static boolean warningStayApply() {
    Calendar currentTime = Calendar.getInstance();
    if (currentTime.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
        return true;
    return false;
}