【问题标题】:joda time plusDays forPattern("dd/mm/yyyy") does not switch to the next monthjoda time plusDays forPattern("dd/mm/yyyy") 不切换到下个月
【发布时间】:2012-09-16 15:28:29
【问题描述】:
DateTime start = DateTimeFormat.forPattern("dd/mm/yyyy").parseDateTime("30/08/2012");

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

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

为什么?

【问题讨论】:

    标签: java time jodatime days


    【解决方案1】:

    您正在混合分钟 (mm) 和月份 (MM)。来自the DateTimeFormat javadoc

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-18
      • 1970-01-01
      • 2010-10-19
      • 2014-08-25
      • 2020-12-25
      • 1970-01-01
      • 2013-08-31
      相关资源
      最近更新 更多