Java 中 LocalDate 属性的编译问题?

Compilation problem with LocalDate attributes in Java?

我正在努力解决我的代码中的问题。在我的 类 中,我有一个日期属性。当我尝试编译我的程序时,错误说它找不到符号,在本地日期的 L 下有一个箭头?我不确定如何进行?谢谢

public class Adventure{
    private LocalDate startDate;
    private LocalDate endDate;

    public void Setdate(int year, int month, int day){
        this.startDate = LocalDate.of(year, month, day);
    }
    public LocalDate getStartDate(){
        return startDate;
    }
    public void SetDuration(int duration){
        this.duration = duration;
        endDate = startDate.plusDate(duration * 7);
    }
    public int getDuration(){
        return duration;
    }
    public LocalDate getEndDate(){
        return endDate;
    }
}  

如果您导入了 java.time.LocalDate 但它仍然无法编译,那么您使用的是 Java 7 或更早版本。 java.time 作为 JSR 310 的一部分在 Java 8 中引入。

然而a backport library for earlier Java versions。 您可以将其添加到您的项目中。