Java Date, Calendar and Time API - Tutorial
The Calendar class’ date/time API is a nifty tool for accurately manipulating date and time values without too much stress or custom coding. It provides direct support for time based objects. This article gives a few examples how this API can be used. . The class java.util.Date was the first implementation which was used for manipulating dates. The class java.util.Calendar was added in Java 1.1 and provides simplified access to storing and manipulating dates. It is recommended to use Calendar if possible. In reality you have to convert frequently from Date to Calendar and vice versa, e.g. during database access you often get a java.sql.Date object. The following explains how to use Calendar and how to convert Dates into Calendar. It also offers a set of methods for converting and manipulating temporal information. In addition to retrieving the current date and time, the Calendar class also provides an API for date arithmetic. The API takes care of the numerous minor adjustments t...