What is the Calendar class?

July 29th, 2009 by uCertify Leave a reply »

The Calendar class is abstract and provides methods to convert the time in milliseconds to the calendar fields such as seconds, minutes, hours, days, weeks, months, and years. It makes the manipulation of dates easy.

The Calendar class does not provide any public constructor. It is instantiated using the Calendar.getInstance() method as follows:

Calendar c = Calendar.getInstance();

The important methods of the Calendar class are as follows:

  • c.add(f1, val): This method adds the value val to the field f1. The field f1 can be a year, a month, a week, an hour, etc.
  • c.roll(f1, val): This method is similar to the add method, with the exception that when a part of the date is changed as a result of addition, its larger part does not change. This means that adding even more than twenty-four hours to the hour field will not change the day field.
Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.