我正在为我的应用程序创建一个调度程序,我想从时间选择器中设置时间。我面临的问题是我正在获取日期时间。这里是代码,请建议如何执行此操作。
TimePickerDialog.OnTimeSetListener t = new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
//etTime.setText(fmtTime.format(myCalendar.getTime()));
Calendar calNow = Calendar.getInstance();
Calendar calSet = (Calendar) calNow.clone();
/*calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
calSet.set(Calendar.MINUTE, minute);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);*/
if(calSet.compareTo(calNow) <= 0){
//Today Set time passed, count to tomorrow
calSet.add(Calendar.DATE, 1);
}
setAlarm(calSet);
}
};