我格式化ZonedDateTime然后尝试解析它并获得以下异常。
public static void main(String[] args){
String timeStr=ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT);
System.out.println(timeStr);
ZonedDateTime.parse(timeStr,DateTimeFormatter.ISO_INSTANT);
}
导致异常
Exception in thread "main" java.time.format.DateTimeParseException: Text '2016-10-05T21:38:26.191Z' could not be parsed: Unable to obtain ZonedDateTime from TemporalAccessor: {MicroOfSecond=191000, MilliOfSecond=191, InstantSeconds=1475703506, NanoOfSecond=191000000},ISO of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
我需要能够将时间转换为该字符串格式。最好的方法是什么?