Period minus(TemporalAmount amountToSubtract) example

Description

Period minus(TemporalAmount amountToSubtract) returns a copy of this period with the specified period subtracted.

Syntax

minus has the following syntax.


public Period minus(TemporalAmount amountToSubtract)

Example

The following example shows how to use minus.


import java.time.Period;
//from w  w w  . java 2s  .c o m
public class Main {
  public static void main(String[] args) {
    Period p = Period.ofMonths(1);
    
    Period l = p.minus(Period.ofMonths(1));
    System.out.println(l);

  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset