我有類似的問題解析AM/PM到 Unable to parse DateTime-string with AM/PM marker無法使用的SimpleDateFormat
我甚至嘗試在該鏈接所提供的解決方案,但它並沒有幫助。
SimpleDateFormat timingFormat = new SimpleDateFormat("h:mm a", Locale.US);
Date l = timingFormat.parse(time);
但我不斷收到 java.text.ParseException:無法解析的日期: 「12:34」。 當我輸入12:34上午
您是否嘗試過解析['timingFormat.setLenient(true);'](http://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#setLenient%28boolean% 29)? – darvids0n 2011-12-19 00:28:14
我在這裏遇到了同樣的問題。我們嘗試了許多變體,但無法解析AM或PM文本,因此請將其關閉並使用24小時制。 「a」或「aa」只能用於格式化DateTime,而不能用於解析字符串。 – 2013-06-03 22:45:55