I want to compare LocalDate with the timestamp in database (Postgres with UTC timezone).
code I wrote
@Query("""
select eve from Events eve
where cast(to_timestamp(pe.timestamp) as LocalDate) = :curDate
""")
List<Event> getAllByDate(LocalDate curDate);
I added both
@PostConstruct
public void init(){
// Setting Spring Boot SetTimeZone
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
and
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
then I tried to run
select to_timestamp(eve.timestamp)
inside @Query where eve.timestamp was 1664584019 and it converted into 2022-10-01 18:39:59.0
First I through it is converting into IST (Indian standard time) but I think that also wrong.
So, Can anybody help me regarding how to convert epoch time to LocalDate to compare with LocalDate?