I use the following code to add a timestamp to a post:
Map<String, Object> postValues = post.toMap(); postValues.put("timeStamp", ServerValue.TIMESTAMP);
On the client side, two timestamp values ββare printed (one for the local creation date and one for the value from the server that I think). How to print only the value received from the server?
Side note for Frank: The code below is called when the user clicks the submit button. This way messageViewHolder is updated twice in my application (see related question ). ViewHolder is updated once with a local time estimate and once with a time server. I want him to update the holder only using server time (once) for practical purposes.
FriendlyMessage friendlyMessage = new FriendlyMessage("bla","bla","bla"); String key = mFirebaseDatabaseReference.child(MESSAGES_CHILD).push().getKey(); Map<String, Object> postValues = friendlyMessage.toMap(); postValues.put("creationDate", ServerValue.TIMESTAMP); childUpdates.put("/"+MESSAGES_CHILD+"/" + key, postValues); Map<String, Object> childUpdates = new HashMap<>(); mFirebaseDatabaseReference.updateChildren(childUpdates);
java android firebase firebase-database
user8237925
source share