I have a model with the following structure
public class OfferModel {
private String mImageUrl;
private String mOfferCode;
private String mOffe
This is how I managed to store Date on Firebase by using the SimpleDateFormat to convert it to only a date without seconds, hours or milliseconds.
public void storeDatetoFirebase() {
handler = new Handler();
runnable = new Runnable() {
@Override
public void run() {
handler.postDelayed(this, 1000);
try {
Date date = new Date();
Date newDate = new Date(date.getTime() + (604800000L * 2) + (24 * 60 * 60));
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd");
String stringdate = dt.format(newDate);
System.out.println("Submission Date: " + stringdate);
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference().child("My_Date");
databaseReference.child("init_date").setValue(stringdate);
} catch (Exception e) {
e.printStackTrace();
}
}
};
handler.postDelayed(runnable, 1 * 1000);
}
and this is how it appears on Firebase:
Hope it helps..