Javatpoint Logo
Javatpoint Logo

Java Period class

Java Period class is used to measures time in years, months and days. It inherits the Object class and implements the ChronoPeriod interface.

Java Period class declaration

Let's see the declaration of java.time.Period class.

Methods of Java Period

Method Description
Temporal addTo(Temporal temporal) It is used to add this period to the specified temporal object.
long get(TemporalUnit unit) It is used to get the value of the requested unit.
int getYears() It is used to get the amount of years of this period.
boolean isZero() It is used to check if all three units of this period are zero.
Period minus(TemporalAmount amountToSubtract) It is used to return a copy of this period with the specified period subtracted.
static Period of(int years, int months, int days) It is used to obtain a Period representing a number of years, months and days.
Period plus(TemporalAmount amountToAdd) It is used to return a copy of this period with the specified period added.

Java Period Example: addTo()

Test it Now



Java Period Example: of()

Test it Now



Java Period Example: minus()

Test it Now



Java Period Example: plus()

Test it Now


Next TopicJava Duration

Youtube For Videos Join Our Youtube Channel: Join Now


  • Send your Feedback to

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA