The java.time package
There are many classes in the java.time
package and its sub-packages. They were introduced as a replacement for other (older packages) that handled date and time. The new classes are thread-safe (hence, better suited for multithreaded processing), and what is also important is that they are more consistently designed and easier to understand. Also, the new implementation follows International Organization for Standardization (ISO) standards as regards date and time formats, but allows any other custom format to be used as well.
We will describe the following five main classes and demonstrate how to use them:
java.time.LocalDate
java.time.LocalTime
java.time.LocalDateTime
java.time.Period
java.time.Duration
All these and other classes of the java.time
package, as well as its sub-packages, are rich in various functionality that covers all practical cases. But we are not going to discuss all of them; we will just introduce the basics...