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

Method toCalendarPeriod

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

Source from the content-addressed store, hash-verified

1859 * @see #toClockPeriod()
1860 */
1861 public Duration<CalendarUnit> toCalendarPeriod() {
1862
1863 if (this.isEmpty()) {
1864 return Duration.ofZero();
1865 }
1866
1867 List<Item<CalendarUnit>> calItems = new ArrayList<>();
1868
1869 for (Item<U> item : this.items) {
1870 if (item.getUnit() instanceof CalendarUnit) {
1871 calItems.add(Item.of(item.getAmount(), CalendarUnit.class.cast(item.getUnit())));
1872 }
1873 }
1874
1875 if (calItems.isEmpty()) {
1876 return Duration.ofZero();
1877 }
1878
1879 return new Duration<>(calItems, this.isNegative());
1880
1881 }
1882
1883 /**
1884 * <p>Extracts a new duration with all contained clock units only. </p>

Callers 2

toCalendarPeriod1Method · 0.80
toCalendarPeriod2Method · 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

toCalendarPeriod1Method · 0.64
toCalendarPeriod2Method · 0.64