Period get(TemporalUnit unit) example
Description
Period get(TemporalUnit unit)
gets the value of the requested unit.
This returns a value for each of the three supported units, YEARS, MONTHS and DAYS.
Syntax
get
has the following syntax.
public long get(TemporalUnit unit)
Example
The following example shows how to use get
.
import java.time.Period;
import java.time.temporal.ChronoUnit;
//from w ww. j a v a 2s . c om
public class Main {
public static void main(String[] args) {
Period p = Period.ofMonths(1);
System.out.println(p.get(ChronoUnit.DAYS));
}
}
The code above generates the following result.