• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calendar.DAY_OF_MONTH  RSS feed

 
Richard Hayward
Ranch Hand
Posts: 187
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today is 1st April 2012.
I'm using xp and my system date is correctly set.



However, this code gives

Calendar.DAY_OF_MONTH=5
According to the api docs:
'The first day of the month has value 1.'


Could anyone tell me why?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calendar.DAY_OF_MONTH is a constant. It doesn't equal the day of the month, it's used to retrieve the day of the month.

So, for instance, once you've got a Calendar object representing the date you want (and look for a static method in the Calendar class that will give you the current date), you can go:
 
Richard Hayward
Ranch Hand
Posts: 187
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Calendar.DAY_OF_MONTH is a constant. It doesn't equal the day of the month, it's used to retrieve the day of the month.

So, for instance, once you've got a Calendar object representing the date you want (and look for a static method in the Calendar class that will give you the current date), you can go:


oh, I see.

Thanks for your help Matthew. I'll experiment with that.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote: . . . look for a static method in the Calendar class . . .
That method isn’t static.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Matthew Brown wrote: . . . look for a static method in the Calendar class . . .
That method isn’t static.

I didn't say it was. The static method I was referring to was to get the Calendar object in the first place.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. My mistake . That other method certainly is static.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!