import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class FutureDateCalculator {
// Function to calculate future date by adding given months
public static LocalDate calculateFutureDate(int monthsToAdd) {
return LocalDate.now().plusMonths(monthsToAdd);
}
public static void main(String[] args) {
LocalDate futureDate = calculateFutureDate(6);
// Define the date format
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// Print the new date
System.out.println("Date six months from now: " + futureDate.format(formatter));
}
}
/*
run:
Date six months from now: 2025-12-11
*/