File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time getting truncated in Weblogic

 
praveenreddy dinnapaty
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using getDate() of ResultSet in my program and I am not able to retrieve the time portion of the date . I have 5/28/2008 5:51:23 PM in my DB and when I use resultSet.getDate() I am getting only 5/28/2008.\
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ANSI SQL's date data type doesn't hold any time information. To match this behaviour java.sql.Date strips out the hours, minutes, seconds and milliseconds. Use a java.sql.Timestamp instead.
 
praveenreddy dinnapaty
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply .I have tried resultset.getTimestamp also but I am not able to get the time portion ....The code is working fine in Tomcat ...When I deploy it on weblogic I am losing the time portion..

please help me
 
Pete Ihlenfeldt
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume that you are certain the database field is of type datetime. If you are uncertain (i.e. if you did not do the database implementation or do not have direct access) you can check using the ResultSetMetaData class:

(after calling rs = stmt.executeQuery()...)


if you are sure it is, then you should be able to get the full timestamp using



That doesn't work?
 
praveenreddy dinnapaty
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are using Date for the database column instead of DateTime ....Do we have to change the column to datetime or is there a way to get the time portion with date column ?

please help me
 
Pete Ihlenfeldt
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which database are you using (want to know before I respond)?
 
praveenreddy dinnapaty
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using oracle 10g....
 
Pete Ihlenfeldt
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I believe you may have to convert that field to a TIMESTAMP in order for it to register with querying drivers as a field that contains both Date and Time portions. 10g also has TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIMEZONE types, but I'll leave that determination to you.

TIMESTAMP is an extension of the DATE datatype, designed to include the additional information. Technically the DATE datatype in Oracle does store time information, but I believe the standardized solution for you is to make the datatype universally visible as a date/Time structure. The ANSI literal for DATE does not include time information ('2008-05-28'), so you end up having to use special Oracle-specific functions (TO_DATE) to specify time information. You don't want to do that. You want your application to be as portable as possible. TIMESTAMP also offers further granularity. DATE's time information only goes down to the second. TIMESTAMP to the millisecond. Better for determining intervals between operations recorded inside of a second.

If you want to read a little more, see...
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/sql_elements001.htm
Find the text "DATE Datatype" and read that and the "TIMESTAMP Datatype" below it.

I think if you use TIMESTAMP, and then use the code I posted earlier, you'll be good to go. I almost always have time fields in business objects declared as java.sql.Timestamp for this very reason.

Good luck... let me know if you have anything else.
nomad
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic