• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

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: 3323
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: 3323
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.
 
A teeny tiny vulgar attempt to get you to buy our stuff
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!