Reputation: 89
I'm creating an app for membership registration I stored uesr information into firestore .My all data is saved into firestore as a string and except join_date it is save as TimeStamp. But When I'm retrieving those data its show me this error
Failed to convert value of type java.util.Date to String
I'm using this code for saving current date(join_date)
members.put("join_date", FieldValue.serverTimestamp());
and I'm retrieving this data as a string in my adapter
holder.mjoinDate.setText(mClip.get(position).getJoin_date());
Upvotes: 0
Views: 970
Reputation: 4191
You are trying to set Date Object in your text field. Please try as follows
Example:
String convertedString = convertDateToString(mClip.get(position).getJoin_date());
holder.mjoinDate.setText(convertedString);
private String convertDateToString (Date date) {
//change according to your supported formate
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
return dateFormat.format(date);
}
Upvotes: 2