2016-07-15 61 views
0

如何将乔纳达时代的秒数转换为LocalDate自从划时代到乔达的LocalDate以来的秒数

例如

long seconds = 1468608443L; 
? LocalDate.fromSeconds(seconds); // does not exist 

什么确实存在是fromDateFieldsfromCalendar

是否有必要先将秒转换为这两件事中的一件?

或者我可以做一个Instant

Instant instant = new Instant(seconds * 1000); 

然后尝试转换,为DateDateTime然后输入到LocalDate。这是完成这个最标准的方法吗?

回答

0
到目前为止

最佳方法:

Instant instant = new Instant(seconds * 1000); 
LocalDate date = instant.toDateTime(SOME_TIME_ZONE).toLocalDate(); 
0

你试过只是做

LocaleDate ld = new LocaleDate(seconds) 

根据documentation这是它如何工作的

+0

'公共LOCALDATE的(长瞬间)'预计毫秒所以'秒* 1000'将是正确的参数 – binoternary