我正在使用ThreeTen並試圖格式化Instant。分開它會更容易,但我很好奇,應該工作嗎?一切從我讀過的即時需要語法分析,並使用該模式的所有組件:ThreeTen並解析即時
@Test
public void testInstants() {
Instant instant = Instant.now();
String dbDatePattern = "YYYY-MM-dd HH:mm:ss.SSS";
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dbDatePattern);
String dbDate = formatter.format(instant);
} catch (Exception ex) {
int dosomething = 1;
}
}
錯誤:org.threeten.bp.temporal.UnsupportedTemporalTypeException:不支持的領域:工作日
DD是DayofWeek的一天而不是DayofWeek。大概扔了一個紅鯡魚,但它似乎很奇怪。