【发布时间】:2016-03-09 12:47:47
【问题描述】:
我正在尝试从import java.time.LocalDate; 创建LocalDate 的实例
我关注this
这是我的代码:
LocalDate sd= LocalDate.parse("2016-2-2");
我遇到了错误:
java.time.format.DateTimeParseException: Text '2016-2-2' could not be parsed at index 5
at java.time.format.DateTimeFormatter.parseResolved0(Unknown Source)
在另一个尝试创建LocalDate 的实例时,我尝试了
LocalDate ed= new LocalDate("2016-2-4");
但它再次抱怨:
The constructor LocalDate(String) is undefined
【问题讨论】:
-
您提供的链接是关于
org.joda.time.LocalDate而不是java.time.LocalDate