java - datetime in sql changes to just date in my application -


i have column in table type datetime, retrieve column java application using jdbc.

my problem when stored 2014-05-13 23:49:18.150 in database, becomes 2014-04-13 in java application.

how date include time (house, seconds , minutes ).

java code

callablestatement = con                     .preparecall("{call getstatusfororder(?,?,?,?,?)}");             callablestatement.setint(1, order.getid());             callablestatement.registeroutparameter(2, java.sql.types.integer);             callablestatement.registeroutparameter(3, java.sql.types.date);             callablestatement.registeroutparameter(4, java.sql.types.date);             callablestatement.registeroutparameter(5, java.sql.types.bit);             callablestatement.execute();             int statusid = callablestatement.getint(2);             date starttime = callablestatement.getdate(3);             date endtime = callablestatement.getdate(4);             boolean isactive = callablestatement.getboolean(5);             system.out.println("isactive = " + isactive);             system.out.println("start date = " + starttime.tostring()); 

use timestamp instead of date, both datetime , datetime2 map java.sql.timestamp.

see documentation.

ps. not forget use callablestatement.gettimestamp instead of callablestatement.getdate.

http://docs.oracle.com/javase/6/docs/api/java/sql/callablestatement.html#gettimestamp(int)


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -