首页javadateJava Data Type - 如何localDate减和加

Java Data Type - 如何localDate减和加

我们想知道如何localDate减和加。
import java.time.LocalDate;

public class Main {
    public static void main(String[] args) {
        LocalDate today = LocalDate.now();

        // plus and minus operations
        System.out.println("10 days after today will be " + today.plusDays(10));
        System.out.println("3 weeks after today will be " + today.plusWeeks(3));
        System.out.println("20 months after today will be "
                + today.plusMonths(20));

        System.out.println("10 days before today will be "
                + today.minusDays(10));
        System.out.println("3 weeks before today will be "
                + today.minusWeeks(3));
        System.out.println("20 months before today will be "
                + today.minusMonths(20));

    }
}