【发布时间】:2020-12-08 12:31:06
【问题描述】:
我有字段LocalDateTime dateTime 的对象。我有以下存储库方法
@Query("select m from MyClass m " +
"where m.dateTime >= :startDate and m.dateTime <= :endDate")
findAllByTradeTimeBetween(@Param("startDate") LocalDate startDate,
@Param("endDate") LocalDate endDate);
如何在此方法中获得LocalDateTime dateTime 的LocalDate。现在我有一个例外
Parameter value [2020-01-31] did not match expected type [java.time.LocalDateTime]
我该如何解决?
【问题讨论】:
-
所以你想要
Date或LocalDate? -
我需要本地日期
-
@deHaar 他的意思是另一个方向
-
@Andronicus 哦,是的...刚刚意识到 ;-) 感谢您的指点...
-
我不确定,但也许你可以在查询 (SQL) 中对其进行格式化,但这似乎不是最好的主意,即使可能......见this question,你可能最终会失去数据库独立性。
标签: java spring spring-boot spring-data-jpa jpql