Henry Ii Henry Ii - 3 months ago 9
Java Question

Drop Time stamp while pulling data from oracle table to java

Currently I am getting date from oracle table as string which is giving me date as well as timesstamp. Is there a way I can drop timestamp and just get the date from table. Currently in my java code Date is declare as string which pulls date and timestamp.Thank you

setDate(rset.getString(1));

Answer

Using ResultSet#getDate() will return just the date component, as a java.sql.Date (which has hours, minutes, seconds, and milliseconds set to zero). You can turn that Date object into a string afterwards.

I would, however, recommend storing date information as a Date, not as a String.

Comments