• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interesting TimeZone issue  RSS feed

 
Nick Hill
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I�ve been stumped on this one for quite some time, and I was curious to see if any of you out there would have a clever solution for it.

Basically, what we�ve got is this:

Object1[ ] = an array of objects returned from an external service. Within these objects, we have a �birthDate� field that is of type �Calendar�. If I look closely at these birthdates, I can see the timezone information is essentially blank (or defaulted, however you want to look at it) as just �GMT�.

Object2[ ] = an array to hold a collection of objects similar (but not completely identical) to Object1[ ]. Looking at the Object2 definition, we also have a �birthDate� field here that is of type �Date� (as in java.util.Date).

To get the data from Object1[ ] to Object2[ ], we�re using a dozer mapping.

So you�re asking �what�s the problem?�

Well, truthfully, when this app runs locally (which for us is US Central Standard Time) there is no problem. The mapping occurs just fine. For example:

Object1[0].Person.birthDate = �05/19/1970 00:00:00 GMT�

Seems to map just fine as:

Object2[0].Person.birthDate = �05/19/1970 00:00:00 CST�

However, we have users of this application all over the country � that�s where the problem comes in: users of this application west of CST encounter this issue (I�ll use Mountain Standard Time as my example):

Object1[0].Person.birthDate = �05/19/1970 00:00:00 GMT�

Maps to:

Object2[0].Person.birthDate = �05/18/1970 23:00:00 MST�

So it�s like something (the JVM?) is trying to account for the hour difference between CST (where the code was written & compiled) and MST (where the end product is being used).

Can anyone think of a clever solution to this? I�ve come up with something that halfway works, but it is a very messy hack fix involving adding the TZ offset back into the �mapped� (Object2[ ].Person.birthDate) date. I�d prefer not to use something like that if there is a more appropriate solution.

Thanks in advance!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nick,

If I've read your Q correctly I'm afraid that your 1/2 hack is probably a good a solution as any :| .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!