JodaTime IllegalArgumentException:格式无效

Nin*_*ing 1 java format exception jodatime

此代码引发“无效格式”或“格式错误”异常:

码:

strDate = "21/10/2015 12:00:00 AM";
format = "dd/MM/yyyy hh:mm:ss a";

DateTime.parse(strDate, DateTimeFormat.forPattern(format)).toDate();
Run Code Online (Sandbox Code Playgroud)

例外:

java.lang.IllegalArgumentException: Invalid format: "21/10/2015 12:00:00 AM"
is malformed at "AM"
Run Code Online (Sandbox Code Playgroud)

怎么了?

我正在使用Joda-Time:2.8.1

(我已经搜索过,并且我认为这是该strDate的正确模式)

Rei*_*eus 5

AM/PM标记的文本可能与您的默认语言环境不同。你可以做

Date date = 
  DateTime.parse(strDate, DateTimeFormat.forPattern(format).withLocale(Locale.US)).toDate();
Run Code Online (Sandbox Code Playgroud)