我有日期 Wed May 08 00:00:00 GMT+06:30 2013。我增加了一天到它通过使用 Joda 时间 日期时间喜欢这样。
Wed May 08 00:00:00 GMT+06:30 2013
DateTime dateTime = new DateTime(date); dateTime.plusDays(1);
当我打印 dateTime 时,我得到这个日期 2013-05-08T00:00:00.000+06:30。Joda 的约会时间一天也没增加。我没有发现任何错误。
2013-05-08T00:00:00.000+06:30
谢谢
The plusDays method is not a mutator. It returns a copy of the given DateTime object with the change made rather than changing the given object.
plusDays
DateTime
If you want to actually change the variable dateTime value, you'll need:
dateTime
DateTime dateTime = new DateTime(date); dateTime = dateTime.plusDays(1);
If you want add days to current date time instance, use MutableDateTime
MutableDateTime dateTime = new MutableDateTime(date); dateTime.addDays(1);