3

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);
Sindri Þór
  • 2,887
  • 3
  • 26
  • 32
  • You may require this [link1](http://stackoverflow.com/questions/7735705/how-to-convert-date-format-to-milliseconds )[link2](http://stackoverflow.com/questions/1459656/how-to-get-the-current-time-in-yyyy-mm-dd-hhmisec-millisecond-format-in-java) – SaravanaRaja Aug 11 '14 at 18:40
  • That totally depends. Are you trying to get the timestamp of an hour/minute combination that took place in the past? Or are you trying to get the timestamp in the future? Or are you trying to get both? – Cruceo Aug 11 '14 at 18:43
  • @SaravanarajaT well this dude is using Date but with timepicker there are no Date, get my drift.. it only gives me int but i want to pas that int into a value of millisecond.. – Sindri Þór Aug 11 '14 at 21:32

1 Answers1

1

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.

Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63