我正在尝试将以前的日期存储在 LocalDate 对象中,但我不确定如何存储。 到目前为止,我一直在使用自己的类,但我想应用 java.time.LocalDate 库。 帮忙?
我的代码: LocalDate theDate = new LocalDate(theYear, theMonth, theDay);
错误信息: LocalDate theDate = new LocalDate(theYear, theMonth, theDay);
最佳答案
像这样尝试:
Java 8 java.time.LocalDate类没有公共(public)构造函数,
public class test {
public static void main(String[] args) {
int theYear=2016;
int theMonth=1;
int theDay=21;
LocalDate theDate = LocalDate.of(theYear,theMonth,theDay);
System.out.println(theDate);
}
}
关于java - 使用 LocalDate 存储日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34917851/