Get the first day of the week in Java
Question:
How to get the first day of the week in Java? Answer:
LocalDate now = LocalDate.now();
LocalDate firstDayOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
Description:
To get the first day of a week based on the current date, use the previousOrSame()
adjuster.
It returns the previous-or-same day-of-week adjuster, which adjusts the date to the first occurrence of the specified day-of-week before the date being adjusted unless it is already on that day in which case the same object is returned.
Reference:
Java previousOrSame reference
Share "How to get the first day of the week in Java?"
Related snippets:
- Get the last Friday of a month in Java
- Get the first Monday of a month in Java
- Get the first day of the week in Java
- Get the first day of the current month in Java
- Get the last day of a month in Java
- Get the number of days between two dates in Java
- Get yesterday's date in Java
- Get tomorrow's date in Java
- Get actual date in Java
Tags:
first day of week, get the Monday of week, java Technical term:
Get the first day of the week in Java