I have an Oracle database which gives +00:00
result for query:
select dbTimezone from dual;
I would like to work with any date/time within my Java app always as UTC.
The table I work with has a column of type Date
which gets default value from sysdate
.
Even though I run my app with -Duser.timezone=UTC
, when I insert to this table and read this Date
column with rs.getTimestamp("DATE_CREATED")
, it is one hour more than expected current UTC
time:
Expected current UTC: 2020-02-04 20:38:12.0
Actual: 2020-02-04 21:38:12.0
I also noticed that select current_date from dual
instead of sysdate
will result in expected current UTC time. Should I change a default value for this column from sysdate
to current_date
(alter table MY_TABLE modify DATE_CREATED default current_date
) or there are other ways to configure timezone within Java app without changing database settings?