Re: [問題] simpledateformat 使用(yyyy-MM-dd HH: …
我只想問一件事情,但是推文很難問...
※ 引述《beeline (Very funny.)》之銘言:
: 使用 simpledateformat(yyyy-MM-dd HH:ss) 出現的錯誤
^^^^^^^^^^^^^^︿
: select xxx from yyy where date=? 類似這樣的查詢子句
: ?裡的資料 我借用simpledateformat來處理
: 先 SimpleDateSimpleDateFormat fmt =
: new SimpleDateFormat("yyyy-MM-dd HH:mm");
^^^^^^^^^^^^^^︿
: java.util.Date dd=fmt.parse("2007-01-02 12:20");
: PreparedStatement 的stmt.set(1, dd.getTime());
: 如果查詢使用(yyyy-MM-dd)是沒有問題
: 但用(yyyy-MM-dd HH:ss)
^^^^^^^^^^^^^^︿
這... 你到底是要 HH:ss 還是 HH:mm
我是沒用過 HH:ss,不知道會不會掛掉,
只是,感覺掛在這裡好像野蠻正常的
另外就是,你沒有提供錯誤訊息
還有,先把 dd 印出來看看是不是跟原來的一樣再說...
: ResultSet rs = stmt.stmt.executeQuery()
: 但是得到的rs.next()會是false...
: 想請問各位 以上的邏輯哪裡有問題嗎?
: 是不是simpledateformat不可使用時跟分呢... 照理說是可以的啊...
: 先謝謝大家
--
侃侃長論鮮窒礙 首頁:http://www.psmonkey.idv.tw
眾目睽睽無心顫 Blog:http://ps-think.blogspot.com
煢居少聊常人事
殺頭容易告白難 歡迎參觀 Java 版(@ptt.cc)精華區 \囧/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.192.103
推
02/24 23:23, , 1F
02/24 23:23, 1F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 4 篇):