With the help of an answer from how to get a list of dates between two dates in java,
How can I get a list of DateTime-Local between two DateTime-Local?
Below are the codes
LocalDateTime fromDate = LocalDateTime.parse("2007-12-03T10:15");
LocalDateTime toDate = LocalDateTime.parse("2107-12-03T10:15");
List<LocalDateTime> dates = new ArrayList<LocalDateTime>();
LocalDateTime current = fromDate;
while (current.isBefore(toDate)) {
dates.add(current);
current = current.plusDays(1);
}
System.out.println(dates);
It prints out
[2007-12-03T10:15, 2007-12-04T10:15, 2007-12-05T10:15, 2007-12-06T10:15, 2007-12-07T10:15, 2007-12-08T10:15...
The date has increased by a day, however, the time doesn't.
How can I increase the time too?