Period withYears(int years) example
Description
Period withYears(int years)
returns a copy of this period with the specified amount of years.
Syntax
withYears
has the following syntax.
public Period withYears(int years)
Example
The following example shows how to use withYears
.
import java.time.Period;
/*from w ww. ja va2 s . c om*/
public class Main {
public static void main(String[] args) {
Period p = Period.ofMonths(1);
Period l = p.withYears(10);
System.out.println(l);
}
}
The code above generates the following result.