Java tutorial
import java.time.Duration; import java.time.LocalTime; import java.time.temporal.TemporalUnit; import java.util.List; public class Main { public static void main(String[] args) { Duration duration = Duration.between(LocalTime.MIDNIGHT, LocalTime.NOON); List<TemporalUnit> l = duration.getUnits(); for (TemporalUnit u : l) { System.out.println(u); } } }