在Android的FirestoreRecyclerAdapter中显示ServerValue.TIMESTAMP [英] showing ServerValue.TIMESTAMP in FirestoreRecyclerAdapter in Android

查看:48
本文介绍了在Android的FirestoreRecyclerAdapter中显示ServerValue.TIMESTAMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在列表中显示服务器时间戳(实际上是日期). FirestoreRecyclerAdapter由此类提供(仅保留与时间戳相关的方法):

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;
    }
}

FirebaseListAdapter用于使用Firebase实时数据库中存在的数据填充ListView.

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

Edit1:

我忘记了这个问题:

有人在适配器中做到这一点吗?怎么解决?

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

推荐答案

FieldValue.serverTimestamp(),正如我在此 发布 .

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.

这篇关于在Android的FirestoreRecyclerAdapter中显示ServerValue.TIMESTAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆