I got a strange problem in android time picker control, when I trying to select 12PM 开发者_开发问答it is returning the value like 12AM I tried in number of ways but I was unable to fix the problem and it is working fine for the other hours like 1,2, etc.
Code snippet as follows -
case TIME_DIALOG_ID:
// Time picker dialog generation
TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mhour = hourOfDay;
mminute = minute;
updatetime();
}
};
return new TimePickerDialog(this, mTimeSetListener, mhour, mminute,
false);
Taking the hours and minutes value from time-picker I shows it into textView as follows -
public void updatetime() {
textShowTime.setText(new StringBuilder().append(pad(mhour)).append(":")
.append(pad(mminute)));
}
private static String pad(int c) {
if (c >= 10)
return String.valueOf(c);
else
return "0" + String.valueOf(c);
}
And lastly I parse the textView value to getting the milliseconds...... But problem as described above are occur.
please help me where I do mistake or suggest any another solution for it. Thanks in advance.
精彩评论