| 1904 | * @see #toClockPeriodWithDaysAs24Hours() |
| 1905 | */ |
| 1906 | public Duration<ClockUnit> toClockPeriod() { |
| 1907 | |
| 1908 | if (this.isEmpty()) { |
| 1909 | return Duration.ofZero(); |
| 1910 | } |
| 1911 | |
| 1912 | List<Item<ClockUnit>> clockItems = new ArrayList<>(); |
| 1913 | |
| 1914 | for (Item<U> item : this.items) { |
| 1915 | if (item.getUnit() instanceof ClockUnit) { |
| 1916 | clockItems.add(Item.of(item.getAmount(), ClockUnit.class.cast(item.getUnit()))); |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | if (clockItems.isEmpty()) { |
| 1921 | return Duration.ofZero(); |
| 1922 | } |
| 1923 | |
| 1924 | return new Duration<>(clockItems, this.isNegative()); |
| 1925 | |
| 1926 | } |
| 1927 | |
| 1928 | /** |
| 1929 | * <p>Extracts a new duration with all contained clock units only. </p> |