Re: [JSP ]MySQL 取值問題
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
推
04/28 18:32, , 1F
04/28 18:32, 1F
推
04/28 19:43, , 2F
04/28 19:43, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):