1
I’m trying to save a data value in the firestore, but I’m having a conversion problem when I take the value of a EditText
and send it to become a date type value. The attempt I made was this one.
private String dateToTimestampString(String dateString){
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date parsedDate;
Timestamp timestamp;
try {
parsedDate = dateFormat.parse(dateString);
timestamp = new Timestamp(parsedDate);
return timestamp.toString();
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
Man EditText
String dt = editDiasTrabalhado.getText().toString();
long dtL = Long.parseLong(dateToTimestampString(dt));
rel.setEditDiasTrabalhado(dtL);
The error being generated is this:
java.lang.Numberformatexception: For input string: "Timestamp(Seconds=1563764400, nanoseconds=0)"
On the field editDiasTrabalhado
I am setting the current date as follows: dd/MM/yyyy
.