Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have date Wed May 08 00:00:00 GMT+06:30 2013. I add one day into it by using Joda-Time DateTime like this.

DateTime dateTime = new DateTime(date);
dateTime.plusDays(1);

When I print dateTime, I got this date 2013-05-08T00:00:00.000+06:30. The joda date time didn't add one day. I haven't found any error.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
329 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.

If you want to actually change the variable dateTime value, you'll need:

DateTime dateTime = new DateTime(date);
dateTime = dateTime.plusDays(1);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...