aspose file tools*
The moose likes JDBC and the fly likes Date difference between Java and db2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Date difference between Java and db2" Watch "Date difference between Java and db2" New topic
Author

Date difference between Java and db2

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello,

I am quite puzzled. I have the following environment:

-iseries DB2
-Jdk 1.5
-Hibernate 3 (jpa)
-Tomcat 5.5

When I have "31st December 2006" in the database, the webapp displays "30th December 2006" and so on.

I don't understand this one-day difference???

Does anyone has some clue of why I get this?

Thanks in advance,

Julien.

PS: The fields are typed java.util.Date
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

That suggests to me that the timezone for the database is not the same as the timezone for the JDK. This could happen even if both of them are running on the iSeries.
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
That is exactly the case Paul: Db2 is in Chicago and Tomcat in Paris. What do you suggest I do in order to avoid this problem bearing in mind I can't put my Tomcat in Chicago?
Julien.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Don't use Dates, use Calendar objects where you can set the time zone and locale.


My Blog: Down Home Country Coding with Scott Selikoff
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Thanks to both of you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date difference between Java and db2