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.
get
has the following syntax.
public long get(TemporalUnit unit)
The following example shows how to use get
.
import java.time.Period; import java.time.temporal.ChronoUnit; //ww w. ja v a 2 s . c o m 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.