MCPcopy Create free account
hub / github.com/MenoData/Time4J / toClockPeriod

Method toClockPeriod

base/src/main/java/net/time4j/Duration.java:1906–1926  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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>

Callers 2

toClockPeriod1Method · 0.80
toClockPeriod2Method · 0.80

Calls 9

isEmptyMethod · 0.95
ofZeroMethod · 0.95
ofMethod · 0.95
isNegativeMethod · 0.95
isEmptyMethod · 0.65
getUnitMethod · 0.45
addMethod · 0.45
getAmountMethod · 0.45
castMethod · 0.45

Tested by 2

toClockPeriod1Method · 0.64
toClockPeriod2Method · 0.64