5. Dates and Times

Most Java programs have to deal with dates and times at one point or another. Fortunately, Java has good built-in support for working with dates and times. Three primary classes are used in most Java programs to store and manipulate times and dates. Those classes are the java.util.Date class, the java.sql.Date class, and the java.util.Calendar class.

Many of the methods in the java.util.Date class have become deprecated, meaning that you should avoid using them in new development. The deprecated methods generally deal with the creation and manipulation of dates. For these operations, the java.util.Calendar class is the preferred mechanism to use. It is also easy to convert between Date and Calendar objects, so if you prefer ...

Get Java™ Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.