Am using following code to return photo objects from arraylist between start and end date (dates are in YYYY-MM-DD string format). if no such objects, it should return empty list.
How can i modify to get the result? There are two parts of code. Here is the first part:
public class Photo {
private String title;
private string date;
public String getTitle() {
return title;
}
public String getDate() {
return date;
}
Here is the second part:
import java.util.ArrayList;
public class Album {
private String albumtitle;
private ArrayList<Photo> photos;
public ArrayList<Photo> datedPhotos(String date1, String date2) {
String startdate = date1;
String enddate = date2;
ArrayList<Photo> photolist = new ArrayList<>();
for (Photo pho : photos) {
if (pho.getDate().compareTo(enddate)< 0 && pho.getDate().compareTo(startdate)>0) {
photolist.add(pho);
}
}
return photolist;
}`