The SpringBoot Query returns null while using TIMESTAMPTZ as the Datatype, but the Query works for other Datatypes like TIMESTAMP etc. My Date formats are like, "2022-07-24 10:11:29.452+00".
The DB screenshot is added below.
Also the date type is defined as follows
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "datem")
private Date datem;
The API calls the below code
Date start = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2022-07-24 10:11:29.452+00");
Date end = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2022-07-24 10:11:49.452+00");
List<MqttMessageParsed> sensor_data = messageParsedRepository.findByCreatedAtBetween(start, end);
The Query function is as follows
@Query("SELECT t FROM MqttMessageParsed t WHERE t.datem BETWEEN :startDate AND :endDate") List<MqttMessageParsed> findByCreatedAtBetween(@Param("startDate")Date start, @Param("endDate")Date end);
The API shoud return the data between the above start and end dates, but it is returning null now. Am i missing something?
Thanks

ZonedDateTimeas the parameter value, notjava.util.Date(orjava.sql.Date)OffsetDateTime?SimpleDateFormatandDate. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Do useOffsetDateTimeandDateTimeFormatter, both from java.time, the modern Java date and time API, as Basil Bourque says in his answer.+00, from your strings.SimpleDateFormatis probably assuming some other time zone, giving you results that are hours off, potentially up to 14 hours.