-1

Hi (I'm new to this so you'll have to forgive me)

I'm trying to construct a Parse query to return all of the objects that were created on a specific day (the time they were created is irrelevant).

I've included the code I have so far below. I passed the date for the objects I'm trying to retrieve into the method. Then I've set two variables, one for the very start of the day and one for the very end of the day. I then used the whereGreaterThanOrEqualTo and whereLessThanmethods to set the end and start date.

The issue i'm having is that it's not returning any objects even though there are several that exist in that class. I have a feeling that it's because Parse Server uses a different date format to the standard java package so I'm not really sure what i should do. Could someone point me in the right direction?

public void updateNotices(Date date){
    if(isNetworkConnected()) {
        date.setTime(0);
        Date endDate = date;
        endDate.setDate(date.getDate()+1);
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Notification");
        query.whereGreaterThanOrEqualTo("createdAt", date);
        query.whereLessThan("createdAt", endDate);
        startLoading();
        query.findInBackground(new FindCallback<ParseObject>() { ...                
shenstone
  • 77
  • 3
  • 9

1 Answers1

0

It would appear you are incorrectly using setTime(). See here: https://www.tutorialspoint.com/java/util/date_settime.htm

This answer appears to show how you'd want to properly create that date: how to create a Java Date object of midnight today and midnight tomorrow?

If fixing that doesn't work, ensure you don't have any ACL/CLP settings that may restrict access to your objects.

If you don't have any ACL/CLP settings, consider setting them. Much easier to do sooner, rather than later.

Jake T.
  • 4,308
  • 2
  • 20
  • 48