我需要将 String 中的以下日期格式解析为 Java LocalDateTime。
所以我将日期作为字符串获取,如下所示:2019-09-20T12:36:39.359
我有以下单元测试:
@Test
public void testDateTime() {
assertEquals(SomeObject.getLocalDate(), LocalDateTime.parse(“2019-09-20T12:36:39.359”, DateTimeFormatter.ofPattern("yyyy-MM-ddThh:mm:ss.SSS")));
}
单元测试失败,出现异常:
java.lang.IllegalArgumentException: Unknown pattern letter: T
at java.time.format.DateTimeFormatterBuilder.parsePattern(DateTimeFormatterBuilder.java:1661)
at java.time.format.DateTimeFormatterBuilder.appendPattern(DateTimeFormatterBuilder.java:1570)
at java.time.format.DateTimeFormatter.ofPattern(DateTimeFormatter.java:536)
如何正确解析这种格式的日期LocalDateTime?
偶然的你
BIG阳
江户川乱折腾
相关分类