• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Why they have named a calendar method like this?

 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear noble ranchers,
We know we can get the date from the Calendar using the method



Actually it is leading to ambiguity as I think it should have been getDate() method.
What do you think?
Regards
 
Marshal
Posts: 70251
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe there ought to have been a Calendar#getDate method, but a Calendar object does not record year, month, day. It records milliseconds since 1st Jan 1970 (negative numbers = before 1970) and calculates the date whenever the get method is called. [Have a look at the code: the values might be cached for future reference and only calculated once.] There are other possible ways to design a Calendar class, but that is the way the Java people at Sun chose to do it.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As usual thanks Campbell!
Regards
Note: Wondering how you are knowing even the trivia of details. That's why you've been a bartender.

 
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ramya narayanan wrote:


Just one note:
Calendar.getInstance() already returns a Calendar object for the current moment in time. The creation of the Date object and using it to set the time of the Calendar is not needed.
 
Campbell Ritchie
Marshal
Posts: 70251
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ramya narayanan wrote:Note: Wondering how you are knowing even the trivia of details.

Keep reading these fora Take notice when somebody tells me I am mistaken.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic