我在 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
提交
取消