use of com.google.cloud.firestore.DocumentReference in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippets method updateServerTimestamp.
/**
* Update document with server timestamp.
*/
void updateServerTimestamp() throws Exception {
db.collection("objects").document("some-id").set(new HashMap<String, Object>()).get();
// [START fs_update_server_timestamp]
DocumentReference docRef = db.collection("objects").document("some-id");
// Update the timestamp field with the value from the server
ApiFuture<WriteResult> writeResult = docRef.update("timestamp", FieldValue.serverTimestamp());
System.out.println("Update time : " + writeResult.get());
// [END fs_update_server_timestamp]
}
Aggregations