U - generic type of calendrical unitspublic abstract class SingleUnitTimeSpan<U extends IsoDateUnit,D extends SingleUnitTimeSpan<U,D>> extends Object implements TimeSpan<U>, Comparable<D>, Serializable
Represents a time span in one calendrical unit only.
TimeSpan.Item<U>| Modifier and Type | Method and Description |
|---|---|
D |
abs()
Yields a copy with the absolute amount.
|
<T extends TimePoint<? super U,T>> |
addTo(T time) |
int |
compareTo(D other) |
boolean |
contains(IsoDateUnit unit) |
boolean |
equals(Object obj) |
int |
getAmount()
Yields the count of units as integer-based amount.
|
long |
getPartialAmount(IsoDateUnit unit) |
List<TimeSpan.Item<U>> |
getTotalLength() |
U |
getUnit()
Yields the associated unit.
|
int |
hashCode() |
D |
inverse()
Yields a copy with the negated amount.
|
boolean |
isEmpty() |
boolean |
isNegative() |
boolean |
isPositive() |
D |
minus(D duration)
Yields a copy with the subtracted duration.
|
D |
minus(int amount)
Yields a copy with the subtracted amount.
|
D |
multipliedBy(int factor)
Yields a copy with the multiplied amount.
|
D |
plus(D duration)
Yields a copy with the added duration.
|
D |
plus(int amount)
Yields a copy with the added amount.
|
<T extends TimePoint<? super U,T>> |
subtractFrom(T time) |
Duration<U> |
toStdDuration()
Converts this instance to a general duration with the same amount and unit.
|
String |
toString()
Prints in ISO-8601-format "PnU" (n=amount, U=unit).
|
public int getAmount()
Yields the count of units as integer-based amount.
public U getUnit()
Yields the associated unit.
public int compareTo(D other)
compareTo in interface Comparable<D extends SingleUnitTimeSpan<U,D>>public List<TimeSpan.Item<U>> getTotalLength()
getTotalLength in interface TimeSpan<U extends IsoDateUnit>public boolean contains(IsoDateUnit unit)
contains in interface TimeSpan<U extends IsoDateUnit>public long getPartialAmount(IsoDateUnit unit)
getPartialAmount in interface TimeSpan<U extends IsoDateUnit>public boolean isNegative()
isNegative in interface TimeSpan<U extends IsoDateUnit>public boolean isPositive()
isPositive in interface TimeSpan<U extends IsoDateUnit>public boolean isEmpty()
isEmpty in interface TimeSpan<U extends IsoDateUnit>public <T extends TimePoint<? super U,T>> T addTo(T time)
addTo in interface TimeSpan<U extends IsoDateUnit>public <T extends TimePoint<? super U,T>> T subtractFrom(T time)
subtractFrom in interface TimeSpan<U extends IsoDateUnit>public String toString()
Prints in ISO-8601-format "PnU" (n=amount, U=unit).
Negative durations will get a preceding sign before "P". Note that gregorian and week-based years have the same representation using the symbol Y.
public D abs()
Yields a copy with the absolute amount.
ArithmeticException - if numeric overflow occurs (only in case of Integer.MIN_VALUE)public D inverse()
Yields a copy with the negated amount.
ArithmeticException - if numeric overflow occurs (only in case of Integer.MIN_VALUE)public D plus(int amount)
Yields a copy with the added amount.
amount - the amount to be addedArithmeticException - if numeric overflow occurspublic D plus(D duration)
Yields a copy with the added duration.
duration - the duration to be addedArithmeticException - if numeric overflow occurspublic D minus(int amount)
Yields a copy with the subtracted amount.
amount - the amount to be subtractedArithmeticException - if numeric overflow occurspublic D minus(D duration)
Yields a copy with the subtracted duration.
duration - the duration to be addedArithmeticException - if numeric overflow occurspublic D multipliedBy(int factor)
Yields a copy with the multiplied amount.
factor - multiplication factor to be appliedArithmeticException - if numeric overflow occursCopyright © 2014–2018. All rights reserved.