This is how I am posting date to firebase:
final long PostTime = new Date().getTime();
and
mDatabaseUsers.child(userID).child("transdate").setValue(PostTime);
I am posting it successfully, and the date is shown like this
I am able to fetch other data using this code:
String currentUid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference uDatabaseReference = FirebaseDatabase.getInstance().getReference().child("Users");
uDatabaseReference.child(currentUid).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String u_name = dataSnapshot.child("name").getValue().toString();
String u_email = dataSnapshot.child("email").getValue().toString();
int post_balance = dataSnapshot.child("balance").getValue(Integer.class);
String bss = String.valueOf(post_balance);
tvname.setText(u_name);
tvemail.setText(u_email);
tvbalance.setText(bss);
}
@Override
public void onCancelled(DatabaseError databaseError) {
throw databaseError.toException();
}
});
My problem now is on date. I do not know how to fetch it. I want my date to show in this format: dd:MM:yyyy
How can I fetch the date from the firebase?
question from:https://stackoverflow.com/questions/65644129/how-to-retrieve-date-from-firebase-to-a-textview-android-studio