我昨天创造了这个精彩的静态方法,它工作得很好 – 昨天
但是,今天它给了我这个错误.我想这是从Z之前的太多0.
任何人都可以推荐如何以简洁的方式(Java 8)解析这种类型的String格式日期 – 请记住它昨天也有效,所以ISO_INSTANT也是String的有效格式?
Caused by: java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: {NanoOfSecond=0, InstantSeconds=1443451604, MilliOfSecond=0, MicroOfSecond=0},ISO of type java.time.format.Parsed
at java.time.LocalDate.from(LocalDate.java:368)
at java.time.LocalDateTime.from(LocalDateTime.java:456)
... 9 more
输入时间抛出异常:“2015-09-28T14:46:44.000000Z”
/**
*
* @param time the time in RFC3339 format (e.g. "2013-07-03T14:30:38Z" )
* @return
*/
public static LocalDateTime parseTimeINSTANT(String time) {
DateTimeFormatter f = DateTimeFormatter.ISO_INSTANT;
return LocalDateTime.from(f.parse(time));
}