Main Topics
Browse All TopicsHi,
Can anyone assist me to convert a date (PST) that is read from Oracle db to user's local time? For instance when PST is 22 Dec 2008, CST(china) is 23 Dec 2008.
Things are working fine when I create a java.util.Date object and convert the same (the commented line in the code) .
Thanks in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi mkumaran1,
I think your function is ok but you need to specify timezone of the Calendar instance to be PST.
calDate = Calendar.getInstance();
calDate.setTimeZone(TimeZo
calDate.setTime(templateDa
The returned value from the function can be both 2008-12-22 and 2008-12-23 depends on date from DB.
It will be 2008-12-23 if date from DB is at least 2008-12-22 08:00.
Guys,
Thank you for the response. My code worked after I modify my query to get the date.
Previous query : SELECT DATE_LAST_EXECUTED
resultSet.getDate(1) was returning "2008-12-22" which is equal to Mon Dec 22 00:00:00 PST 2008. As the hh:mm:ss is 0 the date is displaying incorrectly.
modified query : SELECT to_char(DATE_LAST_EXECUTED
I read the date as a string with above query and converted it to a PST calendar using "dd/mm/yyyy hh:mm:ss a". Then I converted the calendar to user's TZ date.
OK, you're trying to convert from PST to CST.
Basically,
CST = GMT +08:00
PST = GMT -08:00 // sorry for my mistake above
Assumed that PST = 2008/12/22 00:00 (from database)
GMT = PST +08:00 = 2008/12/22 00:00 +08:00 = 2008/12/22 08:00
CST = GMT +08:00 = 2008/12/22 08:00 +08:00 = 2008/12/22 16:00
So, you code should print out Date: 2008/12/22 as the result, right?
As I said above, the minimum of PST should be 2008-12-22 08:00. So it will result in 2008-12-23.
Business Accounts
Answer for Membership
by: bluebelldiscoveryPosted on 2008-12-22 at 19:46:01ID: 23231264
Hi mkumaran1,
You can use this.
Select allOpen in new window