- Instant help with your Java coding problems

Get the first Monday of a month in Java

Question:
How to get the first Monday of a month in Java?
Answer:
LocalDate now = LocalDate.now();

LocalDate firstMonday = now.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY));
Description:

Use the firstInMonth() method, which returns the first in month adjuster, which returns a new date in the same month with the first matching day-of-week. This is used for expressions like 'first Monday in the actual month'.

Share "How to get the first Monday of a month in Java?"