我正在尝试使用 joda 时间解析日期字符串,不幸的是我找不到解析时区的方法。
这是我的最新尝试:
String s = "2013-09-20 13:23:50 Etc/GMT";
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss ZZZ").parseDateTime(s)
结果
java.lang.IllegalArgumentException: Invalid format: "2013-09-20 13:23:50 Etc/GMT" is malformed at "Etc/GMT"
我的模式错误在哪里?
最佳答案
您应该使用2.0
或更高版本的Joda-Time
库。
此功能已在版本 2
中添加。
请参阅release notes 1.6 -> 2.0。
Allow 'Z' and 'ZZ' in format patterns to parse 'Z' as '+00:00' [2827359]
Support parsing of date-time zone IDs like Europe/London
Support parsing of date-time zone names like "EST" and "British Summer Time" These names are not unique, so the new API methods on the builder require you to pass in a map listing all the names you want to be able to parse. The existing method is unaltered and does not permit parsing.
关于java - 使用 joda-time 解析包含时区的日期字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19120569/