java - how to format and display date from database using resultset -
i've written query data database.
string query = "select id, name, address, contactnumber,disease,docassign,joining,roomassign patient"; preparedstatement ps = conn.preparestatement(query); resultset rs = ps.executequery(); resultsetmetadata rsmd = rs.getmetadata(); while (rs.next()) { %> <tr> <td><%=rs.getint("id")%></td> <td><%=rs.getstring("name")%></td> <td><%=rs.getstring("address")%></td> <td><%=rs.getint("contactnumber")%></td> <td><%=rs.getstring("disease")%></td> <td><%=rs.getint("docassign")%></td> <td><%=rs.getdate("joining")%></td> <td><%=rs.getstring("roomassign")%></td> </tr> <% } %>
i'm able display date in jsp table no issues, date i'm displaying below statement.
<td><%=rs.getdate("joining")%></td>
the output below.
2015-07-01
but want in below format (mm/dd/yyyy)
07-01-2015
please let me know how can this.
thanks
use format function in sql format date
format(joining,'mm/yy/yyyy') "select id, name, address, contactnumber,disease,docassign,format(joining,'mm/yy/yyyy'),roomassign patient"
Comments
Post a Comment