我正在尝试将以前的日期存储在LocalDate对象中,但我不确定如何存储。到目前为止,我一直在使用自己的类,但我想应用java.time.LocalDate库。帮助?
我的代码: LocalDate theDate =新LocalDate(theYear,theMonth,theDay);
错误消息: LocalDate theDate =新LocalDate(theYear,theMonth,theDay);
发布于 2016-01-21 08:07:13
就像这样:
Java8 java.time.LocalDate类没有公共构造函数,
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);
}
}发布于 2016-01-21 07:40:49
试试这个-
LocalDate today = LocalDate.now();
LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
LocalDate yesterday = tomorrow.minusDays(2);https://stackoverflow.com/questions/34917851
复制相似问题