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 Standard Organization (ISO) standards as regards the date and time formats, but allows any other custom format to be used as well.
We will describe the main five 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 cover all practical cases. But we are not going...