I'm not sure what to add to the following code to allow the post to have a time specified at the time the post was made...
String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
public void SendButtonClicked(View view){
FirebaseUser mCurrentUser = mAuth.getCurrentUser();
DatabaseReference mDatabaseUsers = FirebaseDatabase.getInstance().getReference().child("Users").child(mCurrentUser.getUid());
final String messageValue = editMessage.getText().toString().trim();
if (!TextUtils.isEmpty(messageValue)){
final DatabaseReference newPost = mDatabase.push();
mDatabaseUsers.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
newPost.child("time").setValue(currentDateTimeString());
newPost.child("content").setValue(messageValue);
newPost.child("username").setValue(dataSnapshot.child("UserName").getValue()).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
}
});
}
private Object currentDateTimeString() {
currentDateTimeString =
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Do i need to implement a method, datasnapshot or would a string suffice?