• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to fetch Timestamp column values from the DB using NamedParameterJdbcTemplate?

 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to fetch the timestamp value from the DB using the below method:

public <T> List<T> query(String sql,
SqlParameterSource paramSource,
RowMapper<T> rowMapper)
throws DataAccessException

But, I am getting the result in the format 2014-03-14. I wanted the result to be in 2014-03-14 10:23:43.

Please suggest the best method to retrieve the Timestamp.
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the data type of the column in the database?
 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Timestamp
 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is of the datatype 'Date'
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Date types don't store time stamps. They store dates only. You need to change the data type to be something like DateTime
 
antsi klando
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I get the code to fetch the date values through any of the query methods?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic