At the start of my application,I have set default timezone as Australia/Perth using Timezone.setDefaultTimezone()
method in java. I am trying to insert a time stamp with Australia timezone in created_date
column. When the save
method of Spring data JPA is called, the time stamp is 4 pm Australia time zone. But, inside DB , it is stored as 4 pm UTC. Our Spring config does not force JDBC to use UTC timezone. No such config was specified. In fact,UTC is not there anywhere in the repository at all.
Problem: I am aware that JDBC driver decides the timezone. Q) Should n't it always take JVM default timezone which in this case is Australia? Q) No matter what timezone I set in the code(either as default timezone or in the date column), it is always UTC in the DB. The numeric part of the timestamp is going correctly though. By any chance, is the JDBC taking DBtimezone instead of JVM's default timezone? Q) Which timezone does JDBC take - JVM 's default or 'DBtimezone' of the DB(in this case,it happens to be the latter)? Or it can be any?
Info: Dbtimezone of DB - select dbtimezone from dual - UTC Sessiontimezone of DB - Asia/Calcutta Created_date column is of type 'TIMESTAMP WITH TIMEZONE'
Note: I tried with java.time classes.. OffsetdateTime and ZonedDateTime but with no success.