DateTime start = DateTimeFormat.forPattern("dd/mm/yyyy").parseDateTime("30/08/2012");
我在上面的开始日期中添加了 10 天,但它不会切换到下个月。但是,下面的代码会。
DateTime start = DateTimeFormat.forPattern("dd/MM/yyyy").parseDateTime("30/08/2012");
为什么 ?
您正在混合分钟 ( 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也使用了相同的模式符号。