Period getUnits()
gets the set of units supported by this period.
The supported units are YEARS, MONTHS and DAYS.
getUnits
has the following syntax.
public List<TemporalUnit> getUnits()
The following example shows how to use getUnits
.
import java.time.Period; /*from w w w.j av a2 s.co m*/ public class Main { public static void main(String[] args) { Period p = Period.ofMonths(1); System.out.println(p.getUnits()); } }
The code above generates the following result.