使用Firestore查询时间戳

huangapple 未分类评论46阅读模式
英文:

Querying Timestamp with Firestore

问题

我在使用Android中查询时间戳的过程中遇到了一些问题。我正在使用以下代码:

final java.util.Date dater = new Date(System.currentTimeMillis());

final Timestamp date = new Timestamp(dater);

db.collection("Subscriptions").whereEqualTo("VendorUID", user.getUid()).whereLessThan("LastDelivered", date)
.get()
.addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if(task.isSuccessful()) {
Log.d(TAG, "Inside");
.
.
.


这个查询对我来说不起作用。Firestore数据库中的日期是5月1日,并以时间戳格式存储。

当我删除查询中的"LastDelivered"部分时,我能够看到日志"Inside"。
我该如何处理这个问题?
英文:

I've been facing some problems with querying Timestamps in Android. I'm using the following code

final java.util.Date dater = new Date(System.currentTimeMillis());
     
final Timestamp date = new Timestamp(dater);
       
db.collection("Subscriptions").whereEqualTo("VendorUID", user.getUid()).whereLessThan("LastDelivered", date)
                .get()
                .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<QuerySnapshot> task) {
                        if(task.isSuccessful()) {
                            Log.d(TAG, "Inside");
.
.
.

This query doesn't work for me. The date in the Firestore Database is 1 May and stored in Timestamp format.

I'm able to see the Log "Inside" when I remove the "LastDelivered" part of query.
How should I go about this?

huangapple
  • 本文由 发表于 2020年5月3日 18:54:02
  • 转载请务必保留本文链接:https://java.coder-hub.com/61573258.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定