Period getUnits() example
Description
Period getUnits()
gets the set of units supported by this period.
The supported units are YEARS, MONTHS and DAYS.
Syntax
getUnits
has the following syntax.
public List<TemporalUnit> getUnits()
Example
The following example shows how to use getUnits
.
import java.time.Period;
//from ww w . j av a 2s .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.