Java Date Time - Period minusDays(long daysToSubtract) example








Period minusDays(long daysToSubtract) returns a copy of this period with the specified days subtracted.

Syntax

minusDays has the following syntax.

public Period minusDays(long daysToSubtract)

Example

The following example shows how to use minusDays.

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

  }
}

The code above generates the following result.