how to add days to java simple date format

前端 未结 2 736
醉梦人生
醉梦人生 2020-11-30 14:33

How should I add 120 days to my current date which I got using simple date format?

I have seen few posts about it but couldn\'t get it to work,

My code is be

2条回答
  •  没有蜡笔的小新
    2020-11-30 15:03

    I would suggest you use Joda DateTime if possible. The advantage is it handles TimeZone very gracefully. Here's how to add days:

    DateTime added = dt.plusDays(120);
    

    Reference: http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTime.html#plusDays(int)

提交回复
热议问题