Posts

Showing posts from February, 2012

Why Time gets truncated with ResutSet getDate() function.

Recently I stuck in an issue on populating date from stored procedure. I am reading a date from a resultset using rs.getDate(), storing in a java.util.Date instance variable and displaying on the screen. Java.util.Date  mydate = rs.getDate(1); Output is only date while time is truncated.  But why …! That confused me a lot. So I google it. Spending lot of time in reading blogs, oracle docs and trying different things on oracle server like checking  NLS_DATE_FORMAT, I am not able to get the time. Next I come across a Timestamp thing in Resultset class. Rs.getTimestamp (int colIndex) When I use it, I immediately get the time.  Now, the important question, why the resultset function getDate() does not return the Time. Now my search is preety narrow. What I found is :- In java, we have java.util.Date for java.sq.Date . So functionalities available in sql.Date are also available in util.Date. But there is one difference, sql.Date stores only Date and not Time of date. To get the