This method returns a copy of this period with the specified amount of days.
package com.logicbig.example.period;
import java.time.Period;
public class WithDaysExample {
public static void main(String... args) {
Period p = Period.of(10, 2, 13);
System.out.println(p);
Period p2 = p.withDays(10);
System.out.println(p2);
Period p3 = p.withDays(-10);
System.out.println(p3);
}
}
Output
P10Y2M13D
P10Y2M10D
P10Y2M-10D