1
DateTime start = DateTimeFormat.forPattern("dd/mm/yyyy").parseDateTime("30/08/2012");

我在上面的开始日期中添加了 10 天,但它不会切换到下个月。但是,下面的代码会。

DateTime start = DateTimeFormat.forPattern("dd/MM/yyyy").parseDateTime("30/08/2012");

为什么 ?

4

1 回答 1

4

您正在混合分钟 ( mm) 和月份 ( MM)。从javadoc_DateTimeFormat

 Symbol  Meaning                      Presentation  Examples
 ------  -------                      ------------  -------
 M       month of year                month         July; Jul; 07
 m       minute of hour               number        30

SimpleDateFormat顺便说一下,Java SE 自己的class也使用了相同的模式符号。

于 2012-09-16T15:31:46.367 回答