0
votes

We are persisting a Java Calendar object into an Oracle TIMESTAMP column using the getTimeInMillis() method. Does Oracle persist this data with a time zone?

I'm assuming not as we are not using the TIMESTAMP WITH TIMEZONE data type. If not, when you query SELECT MY_TIMESTAMP FROM MYTABLE what timezone will Oracle associate with this field?

And what is the correct way to 'cast' this to the timezone you are interested in (ie: UTC)?

1

1 Answers

0
votes

getTimeInMillis()

is independent of the calendar system and the timezone. So in whichever timezone you specify the time in, the time is not gonna vary and getTimeInMillis() will get the accurate time.

And on the persistence -

yes the oracle persist the data with the timezone. But it will add the timezone offset to the value saved.

So that's brings us to the next question of choosing the right timezone -

it is ideal to choose the native timezone. As this scenario is a combination of oracle and java its best to use UTC

Cheers!