Package net.time4j.engine
Class TimeSpan.Item<U>
java.lang.Object
net.time4j.engine.TimeSpan.Item<U>
- Type Parameters:
U- type of time unit
- All Implemented Interfaces:
Serializable
Represents a single item of a time span which is based on only one time unit and has a non-negative amount.
- See Also:
- Serialized Form
-
Method Summary
Modifier and TypeMethodDescriptionbooleanlongYields the non-negative amount.getUnit()Yields the time unit.inthashCode()static <U> TimeSpan.Item<U>of(long amount, U unit)Creates a new time span item.toString()Provides a canonical representation in the format 'P' amount '{' unit '}', for example "P4{YEARS}".
-
Method Details
-
of
Creates a new time span item.
- Type Parameters:
U- type of time unit- Parameters:
amount- amount in units>= 0unit- time unit- Returns:
- new time span item
- Throws:
IllegalArgumentException- if amount is negative
-
getAmount
public long getAmount()Yields the non-negative amount.
- Returns:
- amount in units (
>= 0)
-
getUnit
Yields the time unit.
- Returns:
- time unit
-
equals
-
hashCode
public int hashCode() -
toString
Provides a canonical representation in the format 'P' amount '{' unit '}', for example "P4{YEARS}".
-