我在 Firestore 中有數據,我正在比較其中的時間對象。當我使用查詢等其他對象進行"ref" and "title"查詢時,成功返回了一些數據,但隨著時間的推移,它不返回任何內容。String dateString = "9-26-2018";我將此日期轉換為timestamp并傳入查詢:Timestamp timestamp = new Timestamp(dateString);DateFormat df = DateFormat.getDateTimeInstance();df.setTimeZone(TimeZone.getTimeZone("UTC"));Date utcTime = new Date(df.format(date));System.out.println("MyDates >>" +utcTime + " >> "+ timestamp.toDate());CollectionReference ref = db.collection("news");Query newsQuery = ref.whereEqualTo("time", utcTime );mNewsList.clear();newsQuery.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { if (task.isSuccessful()) { System.out.println("DocumentData >> " + task.getResult().size()); for (QueryDocumentSnapshot document : task.getResult()) { News news = document.toObject(News.class); mNewsList.add(news); } // refreshing recycler view mAdapter.notifyDataSetChanged(); // stop animating Shimmer and hide the layout mShimmerViewContainer.stopShimmerAnimation(); mShimmerViewContainer.setVisibility(View.GONE); } else { System.out.println("Error getting documents."+ task.getException()); } } });我得到的是 task.getResult().size() = 0所以我的問題是如何比較 Firestore 中的時間戳?更新 >> 日期輸出 >>MyDates >>Tue Sep 25 18:30:00 GMT+05:30 2018 >> Wed Sep 26 00:00:00 GMT+05:30 2018
添加回答
舉報
0/150
提交
取消