将java.util.Date对象转换为新的JDK 8/JSR-310 的最佳方法是什么java.time.LocalDate?
Date input = new Date();
LocalDate date = ???
Run Code Online (Sandbox Code Playgroud) 考虑一下代码:
TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd").parse("9999-12-31");
Instant.from(date);
Run Code Online (Sandbox Code Playgroud)
最后一行抛出异常:
Unable to obtain Instant from TemporalAccessor: {},ISO resolved to 9999-12-31 of type java.time.format.Parsed
Run Code Online (Sandbox Code Playgroud)
如何Instant从yyyy-MM-dd模式创建?