看板 java 關於我們 聯絡資訊
java.util.Date mydate=new java.util.Date(); mydate = rs.getTimestamp("login_time"); SimpleDateFormat format = new SimpleDateFormat("y'-'M'-'d H':'m':'s"); //自己改format String dateString = format.format(mydate); 自己改一下 SimpleDateFormat constructor的argument就好。 ※ 引述《a7752035 (uishi)》之銘言: : ※ 引述《a7752035 (uishi)》之銘言: : : 請問一下 : : 我資庫裡面有一資料表 : : --------------------------------- : : | UserID | LoginTime | : : |-------------------------------- : : | a7752035 | 2009-01-23 23:16:25| : : |-------------------------------- : : | uishisy | 2009-03-24 14:08:45| : : Class.forName("com.mysql.jdbc.Driver"); : : Connection con =DriverManager.getConnection : : ("jdbc:mysql://127.0.0.1:3306/health","root","1111"); : : Statement smt=con.createStatement(); : : String sql = "select * from lookorder_gotoadoctor"; : : if(!stdid.equals("")){ : : sql = sql+" where stdid='"+stdid+"'"; : : } : : ResultSet rs = smt.executeQuery(sql); : : while(rs.next()){ : : out.print(rs.getString("LoginTime")); : : } : : 請問有什麼方法可以讓年月日分開顯示? : : out.println(rs.getString("LoginTime")); : 我的意思是 把年月日分開顯示 : 例如顯示出 2009年1 月23 日 23點 16 分25秒 : 我out.println("LoginTime"); 只能顯示出 2009-01-23 23:16:25 : 我想分開顯示 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.128.72.121
PsMonkey:太直接了 >////< 04/28 18:32
kaslrca:好赤裸的呈現 哈 04/28 19:43