Reputation: 155
How can I simply get time, set by the user on time picker widget in android ?
Like this.
timepicker.gettime();
Upvotes: 15
Views: 34376
Reputation: 293
Try it like below.
For picking hour you can use
timePicker.getCurrentHour();
and for picking minutes you can use
timePicker.getCurrentMinute();
and then you can set this hour and minute to any Integer variable. Like
int hour = timePicker.getCurrentHour();
int minute = timePicker.getCurrentMinute();
For picking hour you can use
timePicker.hour;
and for picking minutes you can use
timePicker.minute;
and then you can set this hour and minute to any Integer variable. Like
int hour = timePicker.hour;
int minute = timePicker.minute;
for more information you can refer to this link
http://www.mkyong.com/android/android-time-picker-example/
Upvotes: 18
Reputation: 6178
If you are using below API 23. then you can use
int hour = timePicker.getCurrentHour();
int minute = timePicker.getCurrentMinute();
And after 23 you can use both
int hour = timePicker.getHour();
int minute = timePicker.getMinute();
Upvotes: 12