Reputation: 2927
I am using timepicker. I can get date(calendar) in milliseconds but cant figure out with timepicker
with date i used:
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("US/Central"));
cal.setTimeInMillis(calendarView.getDate());
Date date = new Date(calendarView.getDate() / 1000L);
long timestamp = date.getTime()
//and this works
But i dont know with timePicker becouse i get two int's: hour, min.
Im just out of plays and dont know much more to try.. Could use the help
SOLUTION:
Dummy me just need to say the problem outloud.. Hopfully it will help someone else..
long hour = timePicker.getCurrentHour();
long min = timePicker.getCurrentMinute();
hour = TimeUnit.HOURS.toMillis(hour);
min = TimeUnit.MINUTES.toMillis(min);
Upvotes: 3
Views: 3819
Reputation: 26198
TimePicker
is design for 24hours of day, thus you cant get date within it just hours and minutes within the day.
as the documentation is saying:
A view for selecting the time of day, in either 24 hour or AM/PM mode.
I would recommend using DatePicker to enable you to get the date.
Upvotes: 1