• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Calendar class  RSS feed

 
Bharadwaj Adepu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the piece of code am trying to execute



Iam setting todays date and tring to get the DAY_OF_WEEK, its showing the next months day of same date, why so?
please explain!

This is the output
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using
instead. Calendar indexes the months from 0 to 11, so 10 is actually November.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go through the Calendar class API documentation and you find October isn't 10! Use Calendar.OCTOBER instead.

If you go through the documentation you find a link to "constant field values" and there you find out what the values are.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!