Skip to content

Commit f21a53b

Browse files
authored
Use Timestamp in Date fields (firebase#79)
1 parent b6b08e2 commit f21a53b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

firestore/app/src/main/java/com/google/example/firestore/DocSnippets.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.google.android.gms.tasks.OnSuccessListener;
1111
import com.google.android.gms.tasks.Task;
1212
import com.google.android.gms.tasks.Tasks;
13+
import com.google.firebase.Timestamp;
1314
import com.google.firebase.firestore.CollectionReference;
1415
import com.google.firebase.firestore.DocumentChange;
1516
import com.google.firebase.firestore.DocumentChange.Type;
@@ -349,7 +350,7 @@ public void dataTypes() {
349350
docData.put("stringExample", "Hello world!");
350351
docData.put("booleanExample", true);
351352
docData.put("numberExample", 3.14159265);
352-
docData.put("dateExample", new Date());
353+
docData.put("dateExample", new Timestamp(new Date()));
353354
docData.put("listExample", Arrays.asList(1, 2, 3));
354355
docData.put("nullExample", null);
355356

firestore/app/src/main/java/com/google/example/firestore/kotlin/DocSnippets.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.support.annotation.WorkerThread
66
import android.util.Log
77
import com.google.android.gms.tasks.Task
88
import com.google.android.gms.tasks.Tasks
9+
import com.google.firebase.Timestamp
910
import com.google.firebase.firestore.CollectionReference
1011
import com.google.firebase.firestore.DocumentChange
1112
import com.google.firebase.firestore.DocumentSnapshot
@@ -256,7 +257,7 @@ abstract class DocSnippets(val db: FirebaseFirestore) {
256257
docData["stringExample"] = "Hello world!"
257258
docData["booleanExample"] = true
258259
docData["numberExample"] = 3.14159265
259-
docData["dateExample"] = Date()
260+
docData["dateExample"] = Timestamp(Date())
260261
docData["listExample"] = arrayListOf(1, 2, 3)
261262
docData["nullExample"] = null
262263

0 commit comments

Comments
 (0)