我在执行日期类型(时间戳)的查询时遇到困难。在 cCoud 火库中查询日期字段的正确方法是什么?
String created_view = editTextDataFilter.getText().toString();
String time_variable= "";
try {
time_variable= new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH).format(new SimpleDateFormat(
"dd/mm/yyyy", Locale.ENGLISH).parse(created_view));
}catch (ParseException e){}
db.collection("Students")
.whereGreaterThan("created_at", time_variable)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
alunosList.add(
new Students(
document.getString("name").toUpperCase(),
document.getString("classroom"),
document.getDate("created_at")));
recyclerView.setAdapter(adapter);
}
}
else {
Log.w(TAG, "Error getting documents.", task.getException());
}
}
});
}
我希望输出将日期大于“time_variable”中输入的值的记录,但目前它找不到值。
呼啦一阵风
相关分类