1

AFAIK, java Date type is independent from Timezone which means that it represents specific moment of time as long typed value. I found really weird thing here.

This is the original value i tried to insert.

(http-0.0.0.0-9080-4) 1352955600000 <-- long integer.

(http-0.0.0.0-9080-4) Thu Nov 15 00:00:00 EST 2012 <-- User Friendly Format.

After i finished inserting into Oracle 11g database, the value has changed!

(http-0.0.0.0-9080-4) 1352952000000

(http-0.0.0.0-9080-4) Wed Nov 14 23:00:00 EST 2012

How could this happen?? The more weird thing is it only happens specific environments such as Jboss. I'm currently using below environments.

  • java 1.6
  • ibatis 2.34
  • jboss-5.1 (server)
  • tomcat 6.0 (local)
  • oracle 11g

Is there anybody who can give me a clue or link to be helpful? it really bugging me!!


I adds more information here. I uses Date type in java, and TIMESTAMP WITH TIMEZONE in oracle.

I stored value ("11/15/2012", MM/dd/yyyy, US/Eastern) in Date.

And Sent this value to Oracle using iBatis.And it shows like

12/11/15 00:00:00.000000000 -04:00

which is incorrect. It's time zone should be -05:00 because DST will has ended in November.

And more, when i get this value from my java code,

it returns Wed Nov 14 23:00:00 EST 2012 , which i expected as Thu Nov 15 00:00:00 EST 2012.

Problem Solved.

Thanks Folks. I found the reason. It's known bug of ojdbc driver. Please refer this link.

Community
  • 1
  • 1
chofire
  • 11
  • 2
  • Probably a timezone mismatch between your db and the application (java), see [Insert UTC date in Oracle database with Java and Spring](http://stackoverflow.com/questions/12563553/insert-utc-date-in-oracle-database-with-java-and-spring) – Vincent Malgrat Oct 11 '12 at 15:36
  • What is your database Timezone? – Anjan Biswas Oct 11 '12 at 15:38
  • @VincentMalgrat Thanks! But timezone only matters with "presentation" right? How timezone modify the absolute value over DB?.. – chofire Oct 11 '12 at 15:38
  • Your client session has a default time zone (determined from Locale), when you insert a Date it is converted to the database time zone. – Vincent Malgrat Oct 11 '12 at 15:41
  • In the DB is it a Date column or a long column (whatever the DB-Specific types are in oracle)? – Fildor Oct 11 '12 at 15:42
  • @Annjawn I'm using DB with US/Eastern. But It works well in local environments. This only happen Developer's server which uses same DB! – chofire Oct 11 '12 at 15:43
  • @Fildor The column's data type is TIMESTAMP WITH TIMEZONE. – chofire Oct 11 '12 at 15:44
  • We probably also need to see how it's being used - the fact that it's being modified at all is a bit worrisome. – Clockwork-Muse Oct 11 '12 at 15:45
  • @VincentMalgrat Thanks! Vincent! does client session mean connection between Database and WAS data-source pool right? I'm still wondering that if date has converted according to database time zone, does it affects to its absolute value? – chofire Oct 11 '12 at 15:48
  • I don't know how someone hasn't asked yet, but are you using `java.util.Date` or `java.sql.Date`? If you're using the util one, you might be interested to read [this question about the differences](http://stackoverflow.com/q/2305973/1313143). This may well explain your strange observations. – MarioDS Oct 11 '12 at 16:26
  • @MarioDeSchaepmeester Hi Mario. I'm surely using java.util.Date. Application Developer usually does not use java.sql.Date. cause it's only wrapping class of java.util.Date to identify millisecond value for JDBC driver. – chofire Oct 11 '12 at 17:55

1 Answers1

0

It is known bug of ojdbc. After upgrading library, problem never happened.

Refer this

https://forums.oracle.com/thread/356702

chofire
  • 11
  • 2