我有一个旧程序,我将它升级到 Java 8。现在我想利用 LocalDateTime。我已经更新了实体,并且在数据库中读取的值10-APR-1990
。
但是我收到以下错误:
java.time.format.DateTimeParseException: Text '10-APR-90' could not be parsed at index 3
在我的测试中,我尝试使用DateTimeFormatter
.
测试:
@Test
public void testLocalDateTime() throws Exception {
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("dd-MMM-yy", Locale.US);
Tcan1990 applicant = tcan1990Repository.findOne(new Tcan1990PK("000000009", 888067));
assertEquals(LocalDateTime.parse("10-APR-90",formatter),applicant.getPymtDt());
}