Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dateChooser doesn't add next day in Calendar ?  RSS feed

 
Ranch Hand
Posts: 79
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is
 
Bartender
Posts: 3317
86
  • 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:
 
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: 3317
86
  • 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.
 
BWA HA HA HA HA HA HA! Tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!