我在下午2:25在android Google Calendar中創建了一個鬧鐘。然後我嘗試捕獲事件鬧鐘的意圖,但是當我格式化鬧鐘時間時,它顯示的是不同的時間。Google日曆中的通知時間
這是我的日誌
10-31 14:25:18.475: D/@@@@@ Notify(25637): event name: New event
10-31 14:25:18.475: D/@@@@@ Notify(25637): alarm time formatted: 2013-10-31 02:11
10-31 14:25:18.475: D/@@@@@ Notify(25637): alarm time not formatted: 2013-9-31 2:11
10-31 14:25:18.475: D/@@@@@ Notify(25637): today: 2013-9-31 14:25
10-31 14:25:18.475: D/@@@@@ Notify(25637): today formatted: 2013-10-31 02:25
10-31 14:25:18.480: I/CalendarTest(25637): CalendarTest.onReceive called!
我用這個來格式化我的時間
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
你知道爲什麼有差異?
編輯:格式化時間
Date dtAlarmTime = new Date(alarmTime);
Calendar alarm_cal = Calendar.getInstance();
alarm_cal.setTime(dtAlarmTime);
int alarm_year = alarm_cal.get(Calendar.YEAR);
int alarm_month = alarm_cal.get(Calendar.MONTH);
int alarm_day = alarm_cal.get(Calendar.DAY_OF_MONTH);
int alarm_hour = alarm_cal.get(Calendar.HOUR);
int alarm_minute = alarm_cal.get(Calendar.MINUTE);
如何打印非格式化日期? –