showing ServerValue.TIMESTAMP in FirestoreRecycler

2019-02-26 08:19发布

I wanted to show in the List the servers Timestamp (actually the date). The FirestoreRecyclerAdapter is feeded by this class (only kept the timestamp related methods):

public class Lista {
    private Long timestamp;
    //private Map<String, String> timestamp;

    public Lista() {
        //empty constructor needed
    }

    public Lista(Long timestamp) {
        this.timestamp = timestamp;
        //this.timestamp = timestamp;
    }

    public java.util.Map<String, String> getTimestamp() {
        return ServerValue.TIMESTAMP;
    }
    @Exclude
    public Long getTimestampLong() {
        return timestamp;
    }
}

the FirebaseListAdapter is used to populate a ListView using data present in the Firebase realtime database.

Edit1:

I forgot the question:

Has anyone done that in an Adapter? How can that be solved?

1条回答
混吃等死
2楼-- · 2019-02-26 08:40

The ServerValue.TIMESTAMP is used when setting the timestamp in a Firebase realtime database, while in Cloud Firestore (which is a different product), we are using FieldValue.serverTimestamp(), as explained in my answer from this post.

查看更多
登录 后发表回答