If I call in my app:
System.currentTimeMillis()
the result will be, let's say: 1536842771599, which is: GMT: Thursday, September 13, 2018 12:46:11.599 PM OR in my local: Thursday, September 13, 2018 3:46:11.599 PM GMT+03:00 DST
If I do the following select on the Oracle database installed locally:
select CAST(sys_extract_utc(SYSTIMESTAMP) AS DATE) from dual;
I get, through the following JdbcTemplate code:
jdbc.queryForObject(sqlCommand, new Object[0], Timestamp.class);
Which in my opinion is already wrong because Timestamp usually represents localized time. Further, if I call:
myResult.getTime()
to get the long value, this will convert my time, which was around 12.46 PM, to the value 1536831971599, which is actually: GMT: Thursday, September 13, 2018 9:46:11.599 AM.
Obviously this is not good because it is 2 * GMT+03:00 (6 hours) behind my actual local time, and GMT+03:00 (3 hours) behind UTC time of the Database.
What I'm doing wrong? My only conclusion up until now is to avoid doing a sys_extract_utc on a database and let database return me local time which will be converted to UTC time when I will call getTime on the Timestamp instance.
Any explanation to this?
P.S. Base on the answer that java.sql.Timestamp is UTC, I attach a screenshot of what debugger shows to me, and which is wrong, because it considers the result which is UTC to be GMT+03:00. So, it shows my time as 8.26 + 03:00. My local time is 11.26. If I call getTime on this instance of Timestamp, I will get a long value which if I put into https://www.epochconverter.com/ then I get Friday, September 14, 2018 8:26:06 AM GMT+03:00 DST or Friday, September 14, 2018 5:26:06 AM which is exactly 3 hours behind of what I actually have as UTC!
P.S.2 I use Spring JDBC 4.2.5-RELEASE. Can't use Instant with it, it throws exception that cannot convert Timestamp to Instant because it expects something that derives from Number. I cannot change this JDBC, even version, now, unfortunately.

