在我的应用中,我有以下
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent i= new Intent("MY_ALARM_NOTIFICATION");
i.setClass(this, OnAlarmReceive.class);
i.putExtra("id", id);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id, i,PendingIntent.FLAG_UPDATE_CURRENT);
//
Calendar timeCal = Calendar.getInstance();
timeCal.set(Calendar.HOUR_OF_DAY, hour);
timeCal.set(Calendar.MINUTE, minutes);
timeCal.set(Calendar.DAY_OF_MONTH, day);
timeCal.set(Calendar.MONTH, month) - 1);
timeCal.set(Calendar.YEAR, year);
alarmManager.set(AlarmManager.RTC_WAKEUP, timeCal.getTimeInMillis(), pendingIntent);
但是,这可能会返回给我1414526788222
Tue, 28 Oct 2014 20:06:28 GMT
,但我想要的是Tue, 28 Oct 2014 20:06:00
(没有秒。我一直希望秒数为00)...
答案 0 :(得分:4)
只需将秒数设置为零。
timeCal.set(Calendar.SECOND, 0);