0

I want to store current Date and time in firebase Database, But it is in millsec format.I want to save this in regular format i.e dd-mm-yy hr-ms.I am using SErverValue.Timestamp.

String id=databaseuser.push().getKey();
            User user=new User(id,getname,getgenre,ServerValue.TIMESTAMP);
            databaseuser.child(id).setValue(user);
            Toast.makeText(this, "User Added!..", Toast.LENGTH_SHORT).show();

This shows in millsec format

Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
amol junghare
  • 73
  • 1
  • 1
  • 8

1 Answers1

2

It is a standard practice to store the time as the number of milliseconds since the Unix epoch. When retrieving you can format it into dd-mm-yy or any format you want by using this. You can use the same process to store it in the format you want. However, it isn't recommended.

Alex Mamo
  • 112,184
  • 14
  • 139
  • 167
Sairaj Sawant
  • 1,799
  • 1
  • 10
  • 16