I've got this neat code which generates a list of days between two dates, and then the date of the current day, as well as its position in the list (Most importantly, all the dates are in the same format, which makes it easy to compare them).
//Create list of days
String s = "2018-08-28";
String e = "2018-09-05";
LocalDate start = LocalDate.parse(s);
LocalDate end = LocalDate.parse(e);
List<LocalDate> totalDates = new ArrayList<>();
while (!start.isAfter(end)) {
totalDates.add(start);
start = start.plusDays(1);
}
//Date and place of current day
LocalDate a = LocalDate.now();
int current_day = totalDates.indexOf(a) + 1;
The problem is that while I was playing with this code in a Java IDE, I did not know that some of its parts (.parse() ; .now() ; .isAfter() ; .plusDays()
) were reserved for 26+ level API phones. Or, the maximum API in which my application should work is API 23.
I want to know how I can "downgrade" it in the most efficient way, and I don't know what to do or where to start.