不可解除的日期例外MM / dd / yyyy hh:mm:ss a z

时间:2013-05-08 18:53:24

标签: java simpledateformat

     String inputStr = "05/01/2012 10:51:47 AM PDT";
     String inputFmt = "MM/dd/yyyy hh:mm:ss a z";
     SimpleDateFormat dfLong = new SimpleDateFormat(inputFmt);;
     Date localModifiedDate = dfLong.parse(inputStr);
     System.out.println(localModifiedDate);

给我Unparsable日期例外

1 个答案:

答案 0 :(得分:1)

您的默认Locale可能无法解析AM/PM标记和/或时区。试试ENGLISH Locale

SimpleDateFormat dfLong = new SimpleDateFormat(inputFmt, Locale.ENGLISH);