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
  • 565,676
  • 79
  • 828
  • 807
amol junghare
  • 73
  • 1
  • 1
  • 9

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
  • 130,605
  • 17
  • 163
  • 193
Sairaj Sawant
  • 1,842
  • 1
  • 12
  • 16