Exploring the Date API
The java.time
package was introduced in Java 8 and was designed to replace the previous java.util.Date
, java.util.Calendar
, and java.text.DateFormat
classes. The classes in java.time
represent dates, times, timezones, instants, periods, and durations. The ISO calendar system is followed, which is the de facto world calendar (following Gregorian rules). All the classes are immutable and thread-safe.
It is a large API (https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/time/package-summary.html) with a large number of classes for dealing with dates, with relatively fewer classes dealing with times. Thankfully, despite the large number of methods available, the consistent use of method prefixes makes this manageable. We will look at these API prefixes shortly. But before we do that, let’s discuss the more important date and time classes.
Coordinated Universal Time (UTC)
UTC is the standard by which the world regulates clocks and time...