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'.
Reference:
Java lastInMonth reference
Share "How to get the last Friday of a month 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:
get last Friday, last Friday of a month, get the last Friday in a month with java Technical term:
Get the last Friday of a month in Java