- Instant help with your Java coding problems

Get the last Friday of a month in Java

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

LocalDate lastFriday = now.with(TemporalAdjusters.lastInMonth(DayOfWeek.FRIDAY));
Description:

Use the lastInMonth() method that returns the last in month adjuster, which returns a new date in the same month with the last matching day-of-week. For example, use it with DayOfWeek.FRIDAY value. This is used for expressions like 'last Friday in the current month'.

Share "How to get the last Friday of a month in Java?"