I wish to retrieve only the object of the current date. I have a JSON structure like the following in the firebase database.
Tried this but didn't show anything correctly:
Calendar now = Calendar.getInstance();
int year = now.get(java.util.Calendar.YEAR);
int month = now.get(java.util.Calendar.MONTH);
int day = now.get(java.util.Calendar.DAY_OF_MONTH);
query = mDatabase.orderByKey().orderByChild("date").equalTo(now.toString());
Sample JSON data in Firebase Database
"n4VB8b3Q7SfRrR8ezdaaUaLRHn93"(uid) : {
"-LcGXirH22zeZvaFuOzA"(timestamp) : {
"date" : {
"date" : 12,
"day" : 2,
"hours" : 20,
"minutes" : 4,
"month" : 2,
"seconds" : 0,
"time" : 1552399440382,
"timezoneOffset" : -360,
"year" : 119
},
"id" : "-LcGXirH22zeZvaFuOzA",
"name" : "Testing with year",
"note" : "with year"
},
"-LcGcoUtkFRtP-ugp2kO" : {
"date" : {
"date" : 12,
"day" : 2,
"hours" : 20,
"minutes" : 1,
"month" : 2,
"seconds" : 0,
"time" : 1552399260794,
"timezoneOffset" : -360,
"year" : 119
},
"id" : "-LcGcoUtkFRtP-ugp2kO",
"name" : "Testing for today",
"note" : "Testing for today"
}
I expect the output to be events of only the current date.