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.