• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date and Calendar  RSS feed

 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to Calculate current date + 30 days. If calculated date = 1st of a month then use this date. If it is not the 1st of a month, then use the 1st of the following month.
Example�if today is 15 April 2007, then expiry date will be 1 June 2007.
If today is 2 May 2007, then expiry date will be 1 June 2007.

I want to simplify this code so that It looks pretty...
please help me to do that!!!
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks pretty ok to me, with three exceptions:
1) don't suppress warnings about unused variables. Instead just remove those.
2) the calendar's toString() method is not that great.
3) you should add only 1 month, not 2. You have already added 30 days, so you only need to add a single month. Remember, the add method modifies the Calendar object.

So:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!