Recently had a need to break things out over a given date range into month-long increments. I found a solution that did this, however, I was not happy with it using the old Calendar() API. I set about creating a new implementation for this based on LocalDate.
Now you can see I create a simple util class implementing applyByMonth(), applyByWeek(), and applyByDay(). Each of these take a start/end date, to specify the range. The applyByMonth() and applyByWeek() each take BiFunction Functional interface to pass in the start/end date of the month/week for processing, and expects a return. While applyByDay() is a Function Functional interface for passing in the date of that day.
Each return a List<R> then for you to handle your data further on. Allowing you to generate the data as you see fit, with the information you need.
Discover more from GhostProgrammer - Jeff Miller
Subscribe to get the latest posts sent to your email.