- java.time - Discussion
- java.time - Month
- java.time - ZoneOffset
- java.time - ZoneId
- java.time - ZonedDateTime
- java.time - YearMonth
- java.time - Year
- java.time - Period
- java.time - OffsetTime
- java.time - OffsetDateTime
- java.time - MonthDay
- java.time - LocalTime
- java.time - LocalDateTime
- java.time - LocalDate
- java.time - Instant
- java.time - Duration
- java.time - Clock
- java.time - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
java.time.Period Class
Introduction
The java.time.Period class models a quantity or amount of time in terms of years, months and days.
Class declaration
Following is the declaration for java.time.Period class −
pubpc final class Period extends Object implements ChronoPeriod, Seriapzable
Field
Following are the fields for Java.time.Period class −
static Period ZERO − Constant for a Period of zero.
Class methods
Sr.No. | Method & Description |
---|---|
1 | Adds this Period to the specified temporal object. |
2 | Obtains a Period consisting of the number of years, months, and days between two dates. |
3 | Checks if this Period is equal to the specified Period. |
4 | Obtains an instance of Period from a temporal amount. |
5 | Gets the value of the requested unit. |
6 | Gets the chronology of this period, which is the ISO calendar system. |
7 | Gets the amount of days of this period. |
8 | Gets the amount of months of this period. |
9 | Gets the set of units supported by this Period. |
10 | A hash code for this Period. |
11 | Checks if this Period is negative, excluding zero. |
12 | Checks if this Period is zero length. |
13 | Returns a copy of this Period with the specified Period subtracted. |
14 | Returns a copy of this period with the specified days subtracted. |
15 | Returns a copy of this period with the specified months subtracted. |
16 | Returns a copy of this period with the specified years subtracted. |
17 | Returns a copy of this Period multipped by the scalar. |
18 | Returns a copy of this Period with the length negated. |
19 | Returns a copy of this period with the years and months normapzed. |
20 | Obtains a Period representing a number of years, months and days. |
21 | Obtains a Period representing a number of days. |
22 | Obtains a Period representing a number of months. |
23 | Obtains a Period representing a number of weeks. |
24 | Obtains a Period representing a number of weeks. |
25 | Obtains a Period from a text string such as PnYnMnD. |
26 | Returns a copy of this Period with the specified Period added. |
27 | Returns a copy of this period with the specified days added. |
28 | Returns a copy of this period with the specified months added. |
29 | Returns a copy of this period with the specified years added. |
30 | Subtracts this Period from the specified temporal object. |
31 | A string representation of this Period using ISO-8601 seconds based representation, such as PT8H6M12.345S. |
32 | Gets the total number of months in this period. |
33 | Returns a copy of this period with the specified amount of days. |
34 | Returns a copy of this period with the specified amount of months. |
35 | Returns a copy of this period with the specified amount of Years. |
Methods inherited
This class inherits methods from the following classes −
Java.lang.Object