AryanMahindra
AryanMahindra

Reputation: 1

How can I cast a FieldValue.servertimestamp to a sting an upload it to cloud firestore

String time = String.valueOf(FieldValue.serverTimestamp());

Whenever I upload this to the cloud, it doesn't enter it in the desired format.

How can I force the desired format when uploading this data to cloud?

Upvotes: 0

Views: 110

Answers (1)

Scorps
Scorps

Reputation: 31

Firestore has own field type called "Timestamp". You can in your class create field type Timestamp with Firestore annotation:

@ServerTimestamp
    private Timestamp timeStamp;

And leave this field as null, during uploading firestore will automatically fill this field with server timestamp.

I hope it will help

Upvotes: 1

Related Questions