Last active
January 3, 2016 09:39
-
-
Save jpgough/8444213 to your computer and use it in GitHub Desktop.
An implementation to find the last days in each month for a specific year.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<DayOfWeek> lastDaysOfMonthsInYear(int year) { | |
return Stream.of(Month.values()) | |
.map(month -> LocalDate.now().withYear(year) | |
.with(month) | |
.with(TemporalAdjusters.lastDayOfMonth()) | |
.getDayOfWeek()) | |
.collect(Collectors.toList()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Improved based on this implementation: https://gist.github.com/RichardWarburton/8446478