How to get Date extra from an intent?
android, android-intent, date, java
Solution
Replace:
this.date = new Date(intent.getExtras().getString(DATE_EXTRA));
with:
this.date = (Date)intent.getSerializableExtra(DATE_EXTRA);
and see if that helps.
Problem
I am packing an intent and one of the Extras I add is a date object, like this: ``` intent.putExtra(DATE_EXTRA, t.getDate()); ``` Later, when I reading the extras, I try to get the Date like this: ``` this.date = new Date(intent.getExtras().getString(DATE_EXTRA)); ``` However, this returns an error about the String being empty. I don't think the above is the right way to do it, because I am not looking for a string, but I have not been able to find an `intent.getDateExtra()` method anywhere. What do I do? I know that the date was passed properly, because I can see it while debugging: