public static LocalDate adjustToFirstDayOfWeek ( LocalDate date , DayOfWeek firstDayOfWeek ) { LocalDate newDate = date . with ( DAY_OF_WEEK , firstDayOfWeek . getValue ( ) ) ; if ( newDate . isAfter ( date ) ) { newDate = newDate . minusWeeks ( 1 ) ; } return newDate ; }
Adjusts the given date to a new date that marks the beginning of the week where the given date is located . If Monday is the first day of the week and the given date is a Wednesday then this method will return a date that is two days earlier than the given date .