I want to get all the dates of a month in a list so i can show all the dates from that month on a JSF page. When the month changes the amount of dates has to change accordingly.
I Use Java 8 LocalDate.
How can i best do that?
I want to get all the dates of a month in a list so i can show all the dates from that month on a JSF page. When the month changes the amount of dates has to change accordingly.
I Use Java 8 LocalDate.
How can i best do that?
I'm not sure how can one need to put all the dates of the month in a database, but here's a way to get the List of all the dates of the current month:
LocalDate date = LocalDate.now().withDayOfMonth(1);
LocalDate end = date.plusMonths(1);
List<LocalDate> dates = new ArrayList<>();
while(date.isBefore(end)) {
dates.add(date);
date = date.plusDays(1);
}