joda DateTime解析器错误

| 我使用jodatime来解析日期时间字符串,如下所示:     公共静态void main(String [] args){         字符串s = \“ 2009年7月16日05:20:18 PDT \”;         字符串模式= \“ dd-MMM-yyyy HH:mm:ss z \”;             DateTimeFormatter fm = DateTimeFormat.forPattern(patterns);             DateTime d = fm.parseDateTime(s);             System.out.println(d);     } 我懂了 线程\“ main \”中的异常java.lang.IllegalArgumentException:无效格式:\“ PDT \”格式错误:\“ 2009年7月16日05:20:18 PDT \”格式错误     在org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:683) 怎么了?如何正确解析时区?     
已邀请:
        从
DateTimeFormat
javadoc:   模式语法大部分与ѭ1兼容-时区名称无法解析,并且支持更多符号。所有ASCII字母均保留为模式字母,其定义如下: 最好的选择是退回到
SimpleDateFormat
,然后在
Date#getTime()
的基础上构造
DateTime
String s = \"16-Jul-2009 05:20:18 PDT\";
String pattern = \"dd-MMM-yyyy HH:mm:ss z\";
Date date = new SimpleDateFormat(pattern, Locale.ENGLISH).parse(s);
DateTime d = new DateTime(date.getTime());
System.out.println(d);
    

要回复问题请先登录注册