JodaTime解析日期+时间+半天忽略半天字段

JodaTime parsing date + time + half day is ignoring half day field

我不明白为什么 JodaTime 会忽略日期之后的 AM/PM,例如

public static void main(String[] args) {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MM/yy HH:mm:ss a");
    System.out.println(fmt.parseDateTime("23/06/2016 1:00:00 PM").toString("dd/MM/yy HH:mm:ss a"));
    System.out.println(fmt.parseDateTime("23/06/2016 1:00:00 AM").toString("dd/MM/yy HH:mm:ss a"));
}

输出为

23/06/16 01:00:00 AM
23/06/16 01:00:00 AM

如您所见,输入日期时间相隔 12 小时,但在解析并转换回字符串后,它们都是同一时间。

编辑: 感谢 Sotirios Delimanolis,正确的方法是使用 "hh" 而不是 "HH":

public static void main(String[] args) {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MM/yy hh:mm:ss a");
    System.out.println(fmt.parseDateTime("23/06/2016 1:00:00 PM").toString("dd/MM/yy hh:mm:ss a"));
    System.out.println(fmt.parseDateTime("23/06/2016 1:00:00 AM").toString("dd/MM/yy hh:mm:ss a"));
}

输出为

23/06/16 01:00:00 PM
23/06/16 01:00:00 AM

我找不到任何 documentation,但似乎在使用 H 时忽略(或覆盖)匹配 a(半天)的值代表

hour of day (0~23)

使用h

clockhour of halfday (1~12)