• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date difference between Java and db2

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use Dates, use Calendar objects where you can set the time zone and locale.
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic