A DocumentSnapshot contains data read from a document in a Firestore database. The data can be
extracted with the #getData() or #get(String) methods.
If the DocumentSnapshot points to a non-existing document, getData() and its corresponding
methods will return null. You can always explicitly check for a document's existence by calling
#exists().
Subclassing Note: Firestore classes are not meant to be subclassed except for use in
test mocks. Subclassing is not supported in production code and new SDK releases may break code
that does so.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class DocumentSnapshot (3.32.1)\n\nVersion latestkeyboard_arrow_down\n\n- [3.32.1 (latest)](/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot)\n- [3.32.0](/java/docs/reference/google-cloud-firestore/3.32.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.31.9](/java/docs/reference/google-cloud-firestore/3.31.9/com.google.cloud.firestore.DocumentSnapshot)\n- [3.30.11](/java/docs/reference/google-cloud-firestore/3.30.11/com.google.cloud.firestore.DocumentSnapshot)\n- [3.28.0](/java/docs/reference/google-cloud-firestore/3.28.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.27.2](/java/docs/reference/google-cloud-firestore/3.27.2/com.google.cloud.firestore.DocumentSnapshot)\n- [3.26.5](/java/docs/reference/google-cloud-firestore/3.26.5/com.google.cloud.firestore.DocumentSnapshot)\n- [3.25.1](/java/docs/reference/google-cloud-firestore/3.25.1/com.google.cloud.firestore.DocumentSnapshot)\n- [3.24.3](/java/docs/reference/google-cloud-firestore/3.24.3/com.google.cloud.firestore.DocumentSnapshot)\n- [3.22.0](/java/docs/reference/google-cloud-firestore/3.22.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.21.4](/java/docs/reference/google-cloud-firestore/3.21.4/com.google.cloud.firestore.DocumentSnapshot)\n- [3.20.0](/java/docs/reference/google-cloud-firestore/3.20.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.17.0](/java/docs/reference/google-cloud-firestore/3.17.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.16.3](/java/docs/reference/google-cloud-firestore/3.16.3/com.google.cloud.firestore.DocumentSnapshot)\n- [3.15.7](/java/docs/reference/google-cloud-firestore/3.15.7/com.google.cloud.firestore.DocumentSnapshot)\n- [3.14.4](/java/docs/reference/google-cloud-firestore/3.14.4/com.google.cloud.firestore.DocumentSnapshot)\n- [3.13.2](/java/docs/reference/google-cloud-firestore/3.13.2/com.google.cloud.firestore.DocumentSnapshot)\n- [3.12.1](/java/docs/reference/google-cloud-firestore/3.12.1/com.google.cloud.firestore.DocumentSnapshot)\n- [3.11.0](/java/docs/reference/google-cloud-firestore/3.11.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.10.0](/java/docs/reference/google-cloud-firestore/3.10.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.9.6](/java/docs/reference/google-cloud-firestore/3.9.6/com.google.cloud.firestore.DocumentSnapshot)\n- [3.8.2](/java/docs/reference/google-cloud-firestore/3.8.2/com.google.cloud.firestore.DocumentSnapshot)\n- [3.7.10](/java/docs/reference/google-cloud-firestore/3.7.10/com.google.cloud.firestore.DocumentSnapshot)\n- [3.6.0](/java/docs/reference/google-cloud-firestore/3.6.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.5.0](/java/docs/reference/google-cloud-firestore/3.5.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.4.2](/java/docs/reference/google-cloud-firestore/3.4.2/com.google.cloud.firestore.DocumentSnapshot)\n- [3.3.0](/java/docs/reference/google-cloud-firestore/3.3.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.2.0](/java/docs/reference/google-cloud-firestore/3.2.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.1.0](/java/docs/reference/google-cloud-firestore/3.1.0/com.google.cloud.firestore.DocumentSnapshot)\n- [3.0.21](/java/docs/reference/google-cloud-firestore/3.0.21/com.google.cloud.firestore.DocumentSnapshot) \n\n public class DocumentSnapshot\n\nA DocumentSnapshot contains data read from a document in a Firestore database. The data can be\nextracted with the [#getData()](/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getData__) or [#get(String)](/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_get_java_lang_String_) methods.\n\nIf the DocumentSnapshot points to a non-existing document, getData() and its corresponding\nmethods will return null. You can always explicitly check for a document's existence by calling\n[#exists()](/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_exists__).\n\n**Subclassing Note**: Firestore classes are not meant to be subclassed except for use in\ntest mocks. Subclassing is not supported in production code and new SDK releases may break code\nthat does so. \n\nInheritance\n-----------\n\n[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e DocumentSnapshot \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nMethods\n-------\n\n### \\\u003cT\\\u003eget(FieldPath fieldPath, Class\\\u003cT\\\u003e valueType)\n\n public T \u003cT\u003eget(FieldPath fieldPath, Class\u003cT\u003e valueType)\n\nReturns the value at the field, converted to a POJO, or null if the field or document doesn't\nexist.\n\n### \\\u003cT\\\u003eget(String field, Class\\\u003cT\\\u003e valueType)\n\n public T \u003cT\u003eget(String field, Class\u003cT\u003e valueType)\n\nReturns the value at the field, converted to a POJO, or null if the field or document doesn't\nexist.\n\n### \\\u003cT\\\u003etoObject(Class\\\u003cT\\\u003e valueType)\n\n public T \u003cT\u003etoObject(Class\u003cT\u003e valueType)\n\nReturns the contents of the document converted to a POJO or null if the document doesn't exist.\n\n### contains(FieldPath fieldPath)\n\n public boolean contains(FieldPath fieldPath)\n\nReturns whether or not the field exists in the document. Returns false if the document does not\nexist.\n\n### contains(String field)\n\n public boolean contains(String field)\n\nReturns whether or not the field exists in the document. Returns false if the document does not\nexist.\n\n### equals(Object obj)\n\n public boolean equals(Object obj)\n\nReturns true if the document's data and path in this DocumentSnapshot equals the provided\nsnapshot.\n\n**Overrides** \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)\n\n### exists()\n\n public boolean exists()\n\nReturns whether or not the field exists in the document. Returns false if the document does not\nexist.\n\n### get(FieldPath fieldPath)\n\n public Object get(FieldPath fieldPath)\n\nReturns the value at the field or null if the field doesn't exist.\n\n### get(String field)\n\n public Object get(String field)\n\nReturns the value at the field or null if the field doesn't exist.\n\n### getBlob(String field)\n\n public Blob getBlob(String field)\n\nReturns the value of the field as a Blob.\n\n### getBoolean(String field)\n\n public Boolean getBoolean(String field)\n\nReturns the value of the field as a boolean.\n\n### getCreateTime()\n\n public Timestamp getCreateTime()\n\nReturns the time at which this document was created. Returns null for non-existing documents.\n\n### getData()\n\n public Map\u003cString,Object\u003e getData()\n\nReturns the fields of the document as a Map or null if the document doesn't exist. Field values\nwill be converted to their native Java representation.\n\n### getDate(String field)\n\n public Date getDate(String field)\n\nReturns the value of the field as a Date.\n\n### getDouble(String field)\n\n public Double getDouble(String field)\n\nReturns the value of the field as a double.\n\n### getGeoPoint(String field)\n\n public GeoPoint getGeoPoint(String field)\n\nReturns the value of the field as a GeoPoint.\n\n### getId()\n\n public String getId()\n\nReturns the ID of the document contained in this snapshot.\n\n### getLong(String field)\n\n public Long getLong(String field)\n\nReturns the value of the field as a long.\n\n### getReadTime()\n\n public Timestamp getReadTime()\n\nReturns the time at which this snapshot was read.\n\n### getReference()\n\n public DocumentReference getReference()\n\nGets the reference to the document.\n\n### getString(String field)\n\n public String getString(String field)\n\nReturns the value of the field as a String.\n\n### getTimestamp(String field)\n\n public Timestamp getTimestamp(String field)\n\nReturns the value of the field as a Timestamp.\n\n### getUpdateTime()\n\n public Timestamp getUpdateTime()\n\nReturns the time at which this document was last updated. Returns null for non-existing\ndocuments.\n\n### getVectorValue(String field)\n\n public VectorValue getVectorValue(String field)\n\nReturns the value of the field as a VectorValue.\n\n### hashCode()\n\n public int hashCode()\n\n**Overrides** \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)"]]