I have a REST service with an endpoint that GETs data within a requested interval. The requested interval comes down as two Unix Timestamps in milliseconds of the type Long. Like this:
Long start = 1622648253010;
Long end = 1622651853010;
I have a PostgreSQL database which has a table with a Timestamp column. I need to select some data from that table where the timestamp is between the two Unix Timestamps. However PostgreSQL does not understand Unix Timestamps, so I have to convert the two timestamps to PostgreSQL compatible timestamps before using them in the query. The conversion should be done in Java, and not in the SQL Query.
How do I do that? The only way I know is:
java.sql.Timestamp.from(Instant.ofEpochSecond(
start.getSeconds(), start.getNanos()))
But this does not work.