我有字符串"1/28/2013 3:26:51 PM"
SimpleDateFormat formatter = new SimpleDateFormat("M/dd/yyyy h:mm:ss a");
try {
this.createDate = formatter.parse(xmlPhoto.getCreateDate());
this.shootDate = formatter.parse(xmlPhoto.getShootDate());
} catch (ParseException e) {
e.printStackTrace();
}
我想从这个String中创建一个Date对象,但我得到一个ParseExceprion
和offset = 19.
答案 0 :(得分:5)
AM/PM
标记可能与默认Locale
中的标记不匹配。试试:
new SimpleDateFormat("M/dd/yyyy h:mm:ss a", Locale.ENGLISH)