Hi. I have retrieved time from mysql database. its in th format hh:mm:ss. but i want to display only as hh:mm. wat to do?
Here is a jsp example that fetch the time from the database and display in different format.
<%@page import="java.sql.*"%> <%@page import="java.util.*"%> <%@page import="java.text.*"%> <% Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" ); Statement st=conn.createStatement(); ResultSet rs=st.executeQuery("select * from patient"); SimpleDateFormat sdf=new SimpleDateFormat("hh:mm"); while(rs.next()){ java.sql.Time dbSqlTime = rs.getTime("tob"); java.util.Date date = new java.util.Date(dbSqlTime.getTime()); out.println(sdf.format(date)+"<br>"); %>