【发布时间】:2018-02-22 13:14:36
【问题描述】:
这是我的模型类:
import com.google.firebase.firestore.ServerTimestamp;
import java.util.Date;
public class YourModelClass {
private @ServerTimestamp Date timestamp;
YourModelClass() {}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
@Override
public String toString() {
return "YourModelClass{" +
"timestamp=" + timestamp +
'}';
}
}
当我在 Log 中打印时,我得到了 null
Logger.info("Date", new YourModelClass()+"------"+new YourModelClass().getTimestamp() + "");
这是错误:
Output: 02-22 18:33:12.066 18980-18980/com.spendeye I/Date: YourModelClass{timestamp=null}------null
请告诉我解决方案。
【问题讨论】:
-
你能发布你用来上传服务器时间到firebase的代码吗?而且,在您的 firebase 数据库中,名称与您的 POJO 相同吗?这很重要
标签: java android firebase google-cloud-firestore