wood burning stoves 2.0*
The moose likes Java in General and the fly likes Handling different TimeZone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Handling different TimeZone " Watch "Handling different TimeZone " New topic
Author

Handling different TimeZone

deroshal
Greenhorn

Joined: Aug 17, 2001
Posts: 8
Our EJB application which is browser based JApplet has to accomodate Internationalization(I18N). When ever we write the Date ,we write with time and with the insatnce of "GMT".
The sample code looks as below to write date.
<code>
_stmt.setTimestamp(1, new Timestamp(new java.util.Date().getTime()),Calendar.getInstance(TimeZone.getTimeZone("GMT")));
</code>
Though the user is sitting in a different TimeZone and inserting a record, the insert date will be always the server TimeZone which is different from the user's TimeZone.
Assuming that the serve is in USA and user is in Asia, the user is trying to insert a recod at 13th at 7PM. But that record will be written as 14th at 3AM in the server side due to diffeent TimeZone.
Now, the user tries to retrieve the same record immediately, he may not able to retrieve it because it is wriiten as a different day.
I would like to know how to solvw this different TimeZone issues?
Thanks
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
"deroshal",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
Sean
 
wood burning stoves
 
subject: Handling different TimeZone