Temporal Adjusters Business Dates
TemporalAdjusters turns business rules like next Friday, last day of month, or first Monday into single with() calls on immutable LocalDate values.
Code
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
public class PayrollDates {
public static void main(String[] args) {
LocalDate today = LocalDate.of(2026, 11, 14);
System.out.println("month start: " + today.with(TemporalAdjusters.firstDayOfMonth()));
System.out.println("month end: " + today.with(TemporalAdjusters.lastDayOfMonth()));
System.out.println("next friday: " + today.with(TemporalAdjusters.next(DayOfWeek.FRIDAY)));
System.out.println("prev or same: " + today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)));
System.out.println("first monday: " + today.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)));
System.out.println("year end: " + today.with(TemporalAdjusters.lastDayOfYear()));
}
}How it works
Count the class PayrollDates and the function main as the entire surface area of Temporal Adjusters Business Dates.
Using it
Running the file prints labeled results such as month start:, month end:, next friday: — each operation’s effect is visible in the output.
Key statements
LocalDate today = LocalDate.of(2026, 11, 14);
Interactive Tools for This Topic
Business Days CalculatorCount the weekdays between two dates, excluding weekends and any holidays you list, and see how many calendar and weekend days are involved.Age CalculatorCalculate exact age in years, months, and days between a birth date and a reference date, plus total days and the next birthday countdown.Cron Next Runs CalculatorCompute the next scheduled run times for a standard five-field cron expression, supporting ranges, lists, steps, and day-of-week naming semantics.Duration ConverterConvert between human durations like 1w2d3h45m and total seconds, hours, and minutes with negative support.
FAQ
- What does Temporal Adjusters Business Dates print when run?
- Run it as a complete program — the output lines carry labels such as `month start:`, `month end:`, `next friday:`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.