【发布时间】:2017-04-27 20:02:33
【问题描述】:
我有一个旧程序并将其升级到 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());
}
【问题讨论】:
标签: java unit-testing java-8 localdate