File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes TimeZone conversion in client/server architecture Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "TimeZone conversion in client/server architecture" Watch "TimeZone conversion in client/server architecture" New topic

TimeZone conversion in client/server architecture

Aaron Young

Joined: Apr 29, 2011
Posts: 1
I'm working on a Java application that has all sorts of widgets that allow the user to enter various dates/times. This client sends data through Spring, which passes it on to JBoss, which informs Hibernate, which finally delivers the message to MySQL. The goal: to make my server use GMT and the clients to use whatever they want.

I've developed a small bit of code to calculate timezone conversions for me. And I can use the code at entry, and for retrieval, to do my conversion. But this is messy, and error prone, because if I miss a single display, I'll be showing the user wildly varying times. It also becomes tricky when passing from one GUI element to another. (ie. Is this time already converted?)

Wouldn't it be handy to stick my little conversion code somewhere in between client and server? Then there's no mess, the code is all in one place, and I can always be sure what my timezone is, depending where the code is running. The problem: I have several layers... in which layer does this belong? I've also searched in vain for something I can do in one of these layers to automatically convert for me.

In some cases, I found an option to set the timezone, such as in MySQL. But I worry that if clients across multiple timezones are accessing the server, that the server will be passing on its own timezone to MySQL, instead of the client's, resulting in no timezone conversions for dates. Hence, MySQL might be too "deep" for my purposes. Furthermore, it might be possible to set the JVM timezone, in which cases several layers at once get the new timezone, but the same worry still applies. I am fairly ignorant how these components interact with different timezones...

Can anyone give me some direction? I'm assuming there is some industry standard approach to doing this. Thanks.
Ramon Anger
Ranch Hand

Joined: Apr 19, 2011
Posts: 56

Hi Aaron,

there are some tips at that may help you.


Blackbelt on
Ashsih khurana

Joined: Jul 20, 2013
Posts: 4
I found solution of this problem here.
Ashsih khurana

Joined: Jul 20, 2013
Posts: 4
You can try this one also.
I agree. Here's the link:
subject: TimeZone conversion in client/server architecture
It's not a secret anymore!