user1616685
user1616685

Reputation: 1340

showing ServerValue.TIMESTAMP in FirestoreRecyclerAdapter in Android

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?

Upvotes: 1

Views: 288

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 1

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.

Upvotes: 1

Related Questions