gpt4 book ai didi

java - java.time.LocalDate 导入失败

转载 作者:行者123 更新时间:2023-12-01 06:52:05 25 4
gpt4 key购买 nike

import java.time.LocalDate;
import java.time.Period;

public class DateDiff {

public static void main(String[] args) {
/** The date at the end of the last century */
LocalDate endofCentury = LocalDate.of(2000, 12, 31);
LocalDate now = LocalDate.now();

Period diff = Period.between(endofCentury, now);

System.out.printf("The 21st century (up to %s) is %s old%n", now, diff);
System.out.printf("The 21st century is %d years, %d months and %d days old",
diff.getYears(), diff.getMonths(), diff.getDays());
}
}

未找到本地日期,因为我缺少导入指令

最佳答案

检查您是否使用 JDK 8。
我猜你不是,这就是你的问题。

关于java - java.time.LocalDate 导入失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22760121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com