How do i get date from database other than GMT format?
Trying to get a time stored in a datadase.
select dbtimezone from dual
gives me -07:00
I am using Java program to get the 开发者_StackOverflow中文版Date from Oracle
Column i type of Date.
while i am fetching the time in my java program am getting it as GMT. actually i want the time as it is there in database not converted time. Though i can convert back to -07:00 , i am seeking another way to do because conversion always depends on the dbtimezone of the database using. Can any one help me ? Thanks in advance
That oracle just has one timezone can make life difficult if you deal with different timezones. I've always thought life was easier if you consider timezone a view artifact and represent all times as UTC, then convert in the view. You put the timezone information someplace in the database and convert accordingly.
...actually getting that right can get interesting because you don't want to make the same mistake of being too general again. For example, a client may be based in a particular timezone, but have offices in many. Though an office is in a particular timezone, the activity relating to the time may involve a different timezone etc.
See java.util.TimeZone
, more specifically the getOffset
methods, which return the number of milliseconds to add to the UTC time to get local time. Note that it also considers the daylight saving time.
精彩评论