Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

issue with java.sql.Timestamp

 
ajse ruku
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

regards,
Ajse
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic