how to use FieldValue.serverTimestamp() to custom model class in android

前端 未结 4 1970
北海茫月
北海茫月 2021-01-18 07:04

I am using Firestore as a database and now i want to store server timestamp when user register.

from the Firestore doc

  Map up         


        
4条回答
  •  深忆病人
    2021-01-18 07:28

    You need to change this line of code:

    private long timestamp;
    

    with

    private Map timestamp;
    

    And here are the corresponding public setters and getters:

    public void setTimestamp(Map timestamp) {
        this.timestamp = timestamp;
    }
    public Map getTimestamp() {
        return timestamp;
    }
    

    Remember, that you are setting the timestamp as Map and when you are retrieving, you are retrieving it as a Long.

提交回复
热议问题