从firebase到android检索2018年5月12日15:59:56 UTC-5的时间戳

从firebase到android检索2018年5月12日15:59:56 UTC-5的时间戳,android,firebase,Android,Firebase,我正在尝试从firebase检索字段日期:2018年5月12日15:59:56 UTC-5到我的Android类 编辑:我正在使用firestore,该字段是时间戳 保存为生效日期:2018年5月12日15:59:56 UTC-5 我用这种方式调用数据 currentUserId = auth!!.currentUser!!.uid database!!.collection(BRANCHES.USERS) .document(currentUserId)

我正在尝试从firebase检索字段日期:2018年5月12日15:59:56 UTC-5到我的Android类

编辑:我正在使用firestore,该字段是时间戳 保存为生效日期:2018年5月12日15:59:56 UTC-5

我用这种方式调用数据

 currentUserId = auth!!.currentUser!!.uid

    database!!.collection(BRANCHES.USERS)
            .document(currentUserId)
            .get()
            .addOnSuccessListener {
                try {
                    user = it.toObject(UserUpdated::class.java)
                    if (TextUtils.isEmpty(user.dateOfBirthday.toString())){
                        etUserBirthday?.setText("")
                    } else {                         etUserBirthday?.setText(convertTime(user.dateOfBirthday as Long))
                    }
                } catch (n : NullPointerException){
                    n.printStackTrace()
                }
            }
            .addOnFailureListener {
                it.localizedMessage
            }
这是使用set和get的UserUpdated和fields类

public class UserUpdated{
private Date dateOfBirthday;

public UserUpdated(){}

    public Date getDateOfBirthday() {
    return dateOfBirthday;
}

public void setDateOfBirthday(Date dateOfBirthday) {
    this.dateOfBirthday = dateOfBirthday;
}}

当检索数据时,它从firebase读取字段日期,但我在setDateOfBirthday上得到null,并且无法显示日期,检索字段日期时是否有错误?谁能帮帮我,谢谢

请编辑您的问题,使其更具体。您使用的是实时数据库还是Firestore?您的查询代码是什么?你的数据库结构是什么样的?发布你的数据库结构,同样,如果你在getDate中得到任何值,你应该首先用日志检查,然后你就会知道它是空的还是没有更新,谢谢回复!