Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dateChooser doesn't add next day in Calendar ?

 
Ganesh Pat
Ranch Hand
Posts: 79
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is
 
Tony Docherty
Bartender
Posts: 2958
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know it's not adding a day, you aren't printing out anything and you a setting 'today' to the constant Calendar.DAY_OF_MONTH and not to the current day.
Try running this:
 
Jinu Vijay
Greenhorn
Posts: 20
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



For today's date (20/2/2013), the above code returns:
Cal: 20/2/2013
Cal: 31/2/2013
Cal: 1/3/2013

Incrementing the date, auto increments the month too!
 
Tony Docherty
Bartender
Posts: 2958
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Incrementing the date, auto increments the month too!

Only if you use add(..). If you use roll(..) larger fields are not affected.

BTW I would avoid using the Calendar.DATE constant and use Calendar.DAY_OF_MONTH instead. To Calendar they mean exactly the same thing but the Calendar.DAY_OF_MONTH constant name gives a much clearer meaning of what the constant represents.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic