Get time using time picker android

Sharjeel picture Sharjeel · Mar 10, 2014 · Viewed 30k times · Source

How can I simply get time, set by the user on time picker widget in android ?

Like this.

timepicker.gettime();

Answer

user3395743 picture user3395743 · Mar 10, 2014

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 more information you can refer to this link

http://www.mkyong.com/android/android-time-picker-example/