我有一个TimePicker,我在其中选择小时和分钟。然后我将它设置为日历,如下所示:
private Calendar getCalendar() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR, picker.getCurrentHour());
calendar.set(Calendar.MINUTE, picker.getCurrentMinute());
calendar.set(Calendar.SECOND, 0);
return calendar;
}
问题在于,如果我选择小时:19和41分钟,即19:41之后,当我致电getCalendar().getTimeInMillis()
时,它会返回1415688060910
Tue Nov 11 2014 07:41:00 GMT+0100 (CET)
,所以它扭转它。如果我选择7:41那将是Tue Nov 11 2014 19:41:00 GMT+0100 (CET)
。我做错了什么?
答案 0 :(得分:3)
尝试calendar.set(Calendar.HOUR_OF_DAY, picker.getCurrentHour())
;