Skip to content

Instantly share code, notes, and snippets.

@osscontributor
Last active January 9, 2023 16:46
Show Gist options
  • Save osscontributor/c97dcb69768fcde6e05fe78854d67921 to your computer and use it in GitHub Desktop.
Save osscontributor/c97dcb69768fcde6e05fe78854d67921 to your computer and use it in GitHub Desktop.
import java.time.*
import static java.time.DayOfWeek.*
public class BusinessOperations {
List<DayOfWeek> weekendDays = [SUNDAY, SATURDAY]
LocalDate lastBusinessDay( LocalDate dateInMonth ) {
LocalDate lastDayOfMonth = dateInMonth.withDayOfMonth(dateInMonth.month.length(dateInMonth.leapYear))
((lastDayOfMonth)..(lastDayOfMonth - 2)).find {
!(it.dayOfWeek in weekendDays)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment