Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delay of 5 minutes and 40 seconds

 
Amer Seifeddine
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have sql server 2000 and simple resultset.

SQL:
every date after or equals 1920/01/01 is perfect for below issue however a date with this selection:

select cast('1919-12-31 09:10:45.000' as datetime)

returns using a JDBC and resultset.getTimestamp method a correct date (wrong time) but with 5 minutes and 40 seconds delay eg.

1919-12-31 09:05:05.0.

Do you have a logical effective explanation or fix? Thanks a lot.

Driver: TDS Driver for SQL Server 2003 SP3
Java: SDK 1.4.2
 
Paul Clapham
Sheriff
Posts: 21318
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are casting a string to a timestamp in SQL, which would use SQL's default timezone. Then (I assume, I don't see any code but you mention Java) you format that timestamp as a string in Java, which would use Java's default timezone. So, what are those two default timezones?
 
Amer Seifeddine
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All what i did in a very simple java program is:

System.out.println(rs.getTimestamp (1)+"");

I had a workaround by selecting time as character and that worked!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic