当前日期函数在JPA中返回昨天的日期

I'm trying to get results from MySQL database from JPA Repository with a LESS THAN EQUAL TO condition <= CURRENT_DATE. But the CURRENT_DATE function gives yesterday's date and thus my query does not work as expected. However, running curdate() query on database level gives the correct result. I have tried the same condition in a native query as well and the result is same. Can anyone tell me why is that happening? I've confirmed that the current date function is not giving the correct date by @Query("select current_timestamp from table where id=1"). Surprisingly, CURRENT_TIMESTAMP() and now() gives the correct date but when I try to extract date from it using Date(), same issue. I need Date not timestamp for my condition.

评论