I was trying to save date on firestore database using EditText and DateTimePicker Dialog. The Problem is, date is getting stored as string on server. If I use the FieldValue.serverTimestamp() it only saves the server timestamp in the field but I want to save the date returned by DateTimePicker dialog as timestamp.
FirebaseFirestore db2 = FirebaseFirestore.getInstance();
Map<String, Object> addAnimal = new HashMap<>();
addAnimal.put("dob", editText.getText());
db.collection("users").document("animals")
.set(addAnimal)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "DocumentSnapshot successfully written!");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error writing document", e);
}
});
The Date is getting stored as string:

