Code example for Date

Methods: getDate, getMonth, getYear

0
		} 
	} 
	 
	public void	setAlarmByGettingEvents(Context context, Event event){
		 
		Date curDate = new Date(System.currentTimeMillis());
		iScheduleDB helper = new iScheduleDB(context);
		AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
		AlarmManager aManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
		//从数据库中获得情景模式更改前的情景模式 
		Mode curMode = helper.getModeById(1);
		//若日程是从今天开始 
			if(event.getStartTime().getYear() ==  curDate.getYear() && 
					event.getStartTime().getMonth() == curDate.getMonth() &&
							event.getStartTime().getDate() == curDate.getDate()){
				Log.i(tag, "modifying=======================================================");
				Log.i(tag, "MID=" + (int)(event.getEventId() * 2));
				Log.i(tag, formatter.format(event.getStartTime()));
				 
				//保存当前的情景模式到数据库 
				if(audio.getRingerMode() == AudioManager.RINGER_MODE_NORMAL){
					curMode.setVolume(1);
				} 
				else{ 
					curMode.setVolume(0);
				} 
				if(audio.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON){
					curMode.setVibrate(1);
				} 
				else{ 
					curMode.setVibrate(0);
				}				 
				helper.updateModeById(curMode);
				 
				Intent eIntent = new Intent(context, ModifyReceiver.class);
				Log.i(tag, helper.getModeByEventId((int) event.getEventId()).getName());
				//获得日程的情景模式 
				eIntent.putExtra("VOLUME", helper.getModeByEventId((int) event.getEventId()).getVolume());
				eIntent.putExtra("VIBRATE", helper.getModeByEventId((int) event.getEventId()).getVibrate());
				eIntent.putExtra("eventId", (int)event.getEventId());
				 
				PendingIntent ePendingIntent = PendingIntent.getBroadcast(context, (int)(event.getEventId() * 2), eIntent, 0);//以EventId*2作为标识参数,表明是开始时间
				//为日程的开始设置闹钟 
				aManager.set(AlarmManager.RTC_WAKEUP, event.getStartTime().getTime(), ePendingIntent);
			} 
			//若日程是在今天结束 
			if(event.getEndTime().getYear() ==  curDate.getYear() && 
					event.getEndTime().getMonth() == curDate.getMonth() &&
							event.getEndTime().getDate() == curDate.getDate()){
				Log.i(tag, "resuming=======================================================");
				Log.i(tag, "MID=" + (int)(event.getEventId() * 2 + 1));
				Log.i(tag, formatter.format(event.getEndTime()));
				Log.i(tag, helper.getModeById(1).getName());