2013-03-15 27 views
2

你好我使用get方法在Apache中的servlet通過我的日期時間字符串,它是這樣的字符串轉換爲Mysql的時間戳的servlet的java

http://localhost:8084/example/Time_ser?date=15/03/2013%2004:14:30%20PM 

,我使用

String time=request.getParameter("date"); 

到獲取日期值.....

和我的Java代碼的字符串轉換時間戳以下

給出

但這樣表示

java.text.ParseException: Unparseable date: "15/03/2013 04:14:30 PM" 

錯誤我在做什麼錯了,請幫我..........

+1

下面的答案是正確的。另外,你不需要那個演員。 – jlordo 2013-03-15 12:32:03

回答

4

使用/-因爲你日期的格式爲15/03/2013 04:14:30 PM

DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa"); 
+0

非常感謝你:) – Kumar 2013-03-15 12:43:37

+0

不客氣':D' – 2013-03-15 12:44:26

相關問題