這是我使用正則表達式提取信息的字符串:的Java字符串到日期不可分析日期
2823893a2f91c7507831f140dd7aa75e420477b0 - #0023922: Fixed the message for defaulted bonds ; Thu Oct 25 12:08:25 2012 +0000
這是我用來提取字符串,然後將代碼試圖使它成爲一個日期:
Pattern pattern3 = Pattern.compile(";\\s(.*)");
Matcher matcher3 = pattern3.matcher(s);
matcher3.find();
String t = matcher3.group(1).toString();
try {
Date time = new SimpleDateFormat("dd/MMM/yy hh:mm a").parse(t);
} catch (ParseException e) {
e.printStackTrace();
}
這應該是我的輸入格式:
Thu Oct 25 12:08:25 2012 +0000
而且我要的是使從一個日期上述字符串,它看起來像:
25/Oct/12 12:08 PM
但我不斷收到這些錯誤:
java.text.ParseException: Unparseable date: "Thu Oct 25 12:08:25 2012 +0000"
Fixed the message for defaulted bonds0null
at java.text.DateFormat.parse(DateFormat.java:337)
at GitItem.cultivateGitItem(GitItem.java:42)
at main.main(main.java:9)
java.text.ParseException: Unparseable date: "Thu Oct 25 11:52:39 2012 +0000"
at java.text.DateFormat.parse(DateFormat.java:337)
at GitItem.cultivateGitItem(GitItem.java:42)
at main.main(main.java:9)
這看起來像VCS的輸出......如果'git',爲什麼不使用jgit? (編輯:應閱讀更多;它是混帳) – fge