Fetch DateTime column from mysql in java -
in mysql last reading timestamp column of datetime. want fetch aggreagteusage based on last reading timestamp.
last reading timestamp in yyy-mm-dd hr:min:se format (ex:2015-03-02 09:15:36)
sql = "select aggregateusage sensorhourlyaggregates sensorid=250 , lastreadingtimestamp =?"; preparedstatement prepstmt; prepstmt = (preparedstatement) conn.preparestatement(sql); timestamp sbegin = new java.sql.timestamp(date.gettime()); prepstmt.settimestamp(1, sbegin); sbegin in yyy-mm-dd hr:min:se.nanosec format (ex:2015-03-02 09:15:36.00)
i not able fetch data since both formats differ. how remove
miliseconds time stamp. tried
clendar.clear(calendar.miliseconds) unable fetch
you have convert time-stamp date, following code may you.
timestamp sbegin = new timestamp(/* pass timestamp db */); date date = new date(sbegin.gettime()); system.out.println(date);
Comments
Post a Comment