问题描述
我想在列表中显示服务器时间戳(实际上是日期). 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?
推荐答案
,而在Cloud Firestore(这是另一种产品)中,正在使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!