• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why get different result in different java version

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my database is Microsoft SQL 2000

the database field's type is datetime

my JDBC driver is JTurbo or i-net

I get this field value through calling getTime() in java code.

my question is :

if I run my program in jdk1.3 ,I can get right minute value ,but if run same program in jdk1.4.2
I can not get right minute value.

for example :
in database execute query ,and get result :

realOffdutyDate
----- -------------------
1900-01-01 08:06:00.000

run program in jdk1.3:
get minute : 6

run program in jdk1.4.2:
get minute : 11
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you get the minute-value?
What do the javadocs for 1.3/ 1.4 say?
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post some code snippets.
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one thing to be notice that getMinutes() has been deprecated in Date Class in 1.4.

so if you write rs.getDate() in JDK 1.4 will get only date Part not time part.

and as Adeel said please put some code snippet

thanks
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shailesh,
getMinutes() is deprecated because you are supposed to use Calendar.get(Calendar.MINUTES) instead. This is the first I hear of the actual precision changing. Do you know where you read that? It seems like a mighty big change for Sun who doesn't like to change semantics.
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne,

I know getMinutes () has been deprecated as we are supposed to use Calendar.

and regarding precision changing

This can be individual experience, but I have moticed it few days back
and made this conclusion.

now before posing this reply I have tested same again

my environment details are

JDK 1.5
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

I have created a table having a column date type




and results are below



might be I am missing something.
[ February 08, 2005: Message edited by: Shailesh Chandra ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shailesh,
Getting similar using jdk1.4.2, oracle 10g, oracle thin driver.
[ February 08, 2005: Message edited by: Adeel Ansari ]
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:

It may help.



adeel didn't get you

help for what :roll:
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:
adeel didn't get you
help for what



Shailesh,
I just deleted that because you got confused. However, It was for others. The first sentence is offcourse directed to you. But no worries now there is only one sentence.
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx adeel


I got one link for this.
[ February 08, 2005: Message edited by: Shailesh Chandra ]
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shailesh Chandra,

Regarding your issue with rs.getDate()... java.sql.Date doesn't include the time part, use getTimestamp() (check spelling, I usually mess up the case on TimeStamp/Timestamp).
 
Jeanne Boyarsky
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shailesh,
This really tests what Date.toString() returns. Ideally this would be the same as the precision, but it doesn't have to be.

From the JavaDoc (it's the same in 1.3, 1.4 and 1.5):

A thin wrapper around a millisecond value that allows JDBC to identify this as a SQL DATE. A milliseconds value represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT.

To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.


So it sounds like Date was never supposed to include the hours/minutes/seconds and it was fixed more recently.
 
ameng lai
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne Boyarsky ,

your quote is right.

I do this test as folowing:
step 1 : execute SQL clause , making field realOffdutyDate value is
2005-01-01 08:06:00.000
step 2 : running program in jdk1.3 and jdk1.4, ang get correct result.

I think the genuine reason is that
"A milliseconds value represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT"

as Jeanne Boyarsky's quote



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic