• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What does Calendar.getInstance() Retreive?

 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

i tried to printout Calendar.getInstance() and I am getting the below output. Why I am getting such big output I thought it will get me the current Calendar date.


 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, yes, you are getting the current date and time. And also the default time zone. You can see all of that in your output, which is simply the result of calling the toString() method of the Calendar object. Which by the way is an instance of java.util.GregorianCalendar; toString() tells you that as well.

Of course if you want to work with the Calendar and do things like find out whether it's Saturday or the last day of the month or whether it's more than 30 days after the invoice you have elsewhere in your code, then you can call other methods of the Calendar to do that. You wouldn't use toString() for that purpose.
 
reply
    Bookmark Topic Watch Topic
  • New Topic