✅ Use TemporalAdjusters.next(DayOfWeek.TUESDAY)
import java.time.LocalDate;
import java.time.DayOfWeek;
import java.time.temporal.TemporalAdjusters;
public class NextTuesdayExample {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate nextTuesday = today.with(TemporalAdjusters.next(DayOfWeek.TUESDAY));
System.out.println("Today: " + today);
System.out.println("Next Tuesday: " + nextTuesday);
}
}
🔹 Output Example:
Today: 2025-04-15
Next Tuesday: 2025-04-22
🔸 Bonus: If Today Is Tuesday and You Want the Next One
TemporalAdjusters.next()→ always moves to the next one, even if today is TuesdayTemporalAdjusters.nextOrSame()→ includes today if it’s already Tuesday
LocalDate nextOrSameTuesday = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.TUESDAY));