Last active
September 11, 2018 14:30
-
-
Save Tombarr/c183317a46088a2812f81073d3719e5e to your computer and use it in GitHub Desktop.
TemporalAdjuster for adjusting a date to the last working business day
This file contains hidden or 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 static TemporalAdjuster LAST_WORKING_DAY = TemporalAdjusters.ofDateAdjuster(lastDayOfMonth -> { | |
int daysToSubtract = Math.max(0, lastDayOfMonth.getDayOfWeek().getValue() - DayOfWeek.FRIDAY.getValue()); | |
return lastDayOfMonth.minusDays(daysToSubtract); | |
}); | |
// Example Usage | |
LocalDate.now().with(LAST_WORKING_DAY); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment