There are many classes in the java.time package and its sub-packages. They were introduced as a replacement for other—older—packages that handle date and time. The new classes are thread-safe (so better suited for multithreaded processing) and, no less important, are more consistently designed and easier to understand. Also, the new implementation follows the International Standard Organization (ISO) for date and time formats, but allows the use of any other custom format too.
We will describe the main five classes and demonstrate how to use them:
- java.util.LocalDate
- java.util.LocalTime
- java.util.LocalDateTime
- java.util.Period
- java.util.Duration
All these, and other classes of the java.time package and its sub-packages, are rich in various functionalities that cover all practical and any imaginable cases. But we are not going to cover all of them...