How does Postgres compare a timezone-less java.util.Date with a Timestamp?

We have a Postgres table that has two Timestamp columns, prc_sta_dt and prc_end_dt. We check to see whether a java.util.Date falls in between the start and end dates.

Here is some of the Java code, which is simplified but gets the point across.

// This format expects a String such as 2018-12-03T10:00:00

// With a date and a time, but no time zone

String timestamp = "2018-12-03T10:00:00";

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

Date searchDate = formatter.parse(timestamp);

// Here's the Postgres query

String query = "select promotion_cd from promotions " +

"where prc_sta_dt <= :srch_dt and prc_end_dt >= :srch_dt";

Map

Read More »

By: StackOverFlow - Monday, 3 December

Related Posts