我正在尝试使用Firebase Firestore在Android客户端中添加时间戳字段.
根据文件:
用于标记要使用服务器时间戳填充的日期字段的注释.如果正在编写的POJO对于@ ServerTimestamp-annotated字段包含null,则它将替换为服务器生成的时间戳.
但是当我尝试时:
@ServerTimestamp
Date serverTime = null; // I tried both java.util.Date and java.sql.Date
//...
Map<String, Object> msg = new HashMap<>();
// ... more data
msg.put("timestamp", serverTime);
Run Code Online (Sandbox Code Playgroud)
在Cloud Firestore数据库中,此字段始终为null.