This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes issue with java.sql.Timestamp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "issue with java.sql.Timestamp" Watch "issue with java.sql.Timestamp" New topic

issue with java.sql.Timestamp

ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 196
Hi ,

I am struggling with one issue.
In websphere 6.1/oracle10g , if i do java.sql.Timestamp.setTime(0) then its returning 1970-01-01 05:30:00.0

but the same code in weblogic/Oracle10g is working fine. For example if timestamp value is 2010-07-21 09:04:35.317 , its becoming
2010-07-21 09:04:35.0 after setTime(0).

Why websphere is returning 1970-01-01 05:30:00.0 , that i am failed to understand.

Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 276

That time is the Epoch (in your timezone). Computers measure all dates and times from that day. So when you call setTime(0), you're saying "set this timestamp to be 0 milliseconds after the Epoch".

Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
setTime(long time) shoud do this (according to docs):

Sets this Timestamp object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

I agree. Here's the link:
subject: issue with java.sql.Timestamp
It's not a secret anymore!