Period negated() example

Description

Period negated() returns a new instance with each amount in this period negated.

Syntax

negated has the following syntax.


public Period negated()

Example

The following example shows how to use negated.


import java.time.Period;
/*from   w  w w  .  j av a  2 s .co  m*/
public class Main {
  public static void main(String[] args) {
    Period p = Period.ofMonths(123);
    
    Period l = p.negated();
    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