我必须将 a 解析为StringUTC 中的时间戳。可以有这些String格式:
YYYY-MM-DDThh:mm:ss.sssZYYYY-MM-DDThh:mm:ss.sss+/-hh:mmYYYY-MM-DDThh:mm:ss.sss(考虑到 UTC,所以Z在末尾添加一个)
这样做并避免的最佳方法是什么:
try {
firstDateTimeFormatter.parse(string, Instant::from).toEpochMilli();
} catch (DateTimeParseException e) {
try {
secondDateTimeFormatter.parse(string, Instant::from).toEpochMilli();
} catch (DateTimeParseException e2) {
thirdDateTimeFormatter.parse(string, Instant::from).toEpochMilli();
}
}