I have JSONArray that have 57 JSONObjects, each object has 8 key/value pair properties. In which there is a “publishdate” property. I want to fetch each objects that has “publishdate” within a month. I am using Joda-Time library for date computation.
Here is my code.
Here is my image that shows JSONArray of JSONObjects.
Which data structure is best for above scenario ArrayList or any other?
I would rather prefer to add dates in Arraylist and use Collection.sort(list) to sort the dates and split the list based on variable month.
1.Store all dates in a Arraylist
2.Use Collection.sort(list) to sort the dates by either asc or desc depending on the requirement
3.Split the list by navigating through the entries and check if month retrieved is different to previous entry, if so populate in new Arraylist and repeat for rest of the entries.