.0 is appending at lat of timestamp value while fetching using java JDBC

General
Enthusiast

.0 is appending at lat of timestamp value while fetching using java JDBC

in table I am having a value timestamp "2014-03-15 06:12:35". But while selecting using java JDBC I am getting "2014-03-15 06:12:35.0".

I tried both resultSet.getString and resultSet.getTimestamp

How to resolve this issue. Please advice.

3 REPLIES
Fan

Re: .0 is appending at lat of timestamp value while fetching using java JDBC

It is not a problem, you get valid timestamp and can use it  in the next java code.  java.sql.Timestamp represents the timestamp (year, month, day, hour, minute, second, millisecond) and  '0' is default value for milliseconds. 

Terradata allowes set the  timestamp(n) data type where  n  is the number of digits in the fractional part of second (if you need milliseconds set type timestamp(3))

Teradata Employee

Re: .0 is appending at lat of timestamp value while fetching using java JDBC

The JDK built-in method java.sql.Timestamp.toString prints the Timestamp value with the trailing ".0"

That is not under the control of the database or the JDBC Driver.

What exactly is the problem? You don't like the trailing ".0" ?

Enthusiast

Re: .0 is appending at lat of timestamp value while fetching using java JDBC

Yes. I dont need a trailing ".0".

I have formatted the timestamp as below and it worked for me,

SimpleDateFormat dateFormat = new SimpleDateFormat(

"yyyy-MM-dd HH:mm:ss");