Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Passing Date in putExtra

I'm launching an activity and would like to pass a Date(Time) value to it. I've passed all my other parameters with i.putExtra("noteName", "Hello World") but I'm clueless on how to pass the date value and then retrieve it as a date with getExtra().

I can easily use i.putExtra("noteDate",noteDate);

but then how do i retrieve it in the Activity's onCreate(); I don't see an extras.getDate() ?

Should I convert it to Float and then back (in the Activity)?

Thanks

like image 957
Hein du Plessis Avatar asked Mar 21 '11 18:03

Hein du Plessis


1 Answers

Use date.getTime() and date.setTime() and transfer it as a Long.

i.putExtra("date", date.getTime());  Date d = new Date(); d.setTime(i.getLongExtra("date", -1)); 
like image 188
Robby Pond Avatar answered Oct 02 '22 01:10

Robby Pond