There are times in the past when we tried to measure the period between two date instances but, due to the lack of an API prior to Java 8 and also lack of proper support to capture this information, we resorted to different means. We remember using SQL-based approaches to process such information. But from Java 8 and onward, we have a new class, java.time.Period, which can be used to capture a period between two date instances in terms of the number of years, months, and days.
Also, this class supports parsing ISO 8601 standard-based strings for representing the period. The standard states that any period can be represented in the form of PnYnMnD, where P is a fixed character to represent the period, nY stands for the number of years, nM for the number of months, and nD for the number of days. For example, a period of...