Use a PeriodFormatter to convert a Period to a String.
Periods are immutable. Mutating operations return the new result leaving the original unchanged.
Example:
Period p1 = Period.at(3, WEEK).and(2, DAY).inFuture(); Period p2 = p1.and(12, HOUR);
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final int[] | |
| pack-priv final boolean | |
| pack-priv final byte |
| Access | Constructor and Description |
|---|---|
| private | |
| pack-priv | Period(int timeLimit, boolean inFuture, int[] counts)
Package private constructor used by setters and factory. |
| Modifier and Type | Method and Description |
|---|---|
| public Period | |
| public static Period | |
| public Period | |
| private static void | |
| public boolean | Returns: true if rhs is a Period and is equal to thisthe object to compare to rhs)Overrides java. |
| public boolean | |
| public float | |
| public int | |
| public Period | |
| public Period | Returns: the new Periodtrue if the time is in the future future)Mark the duration as extending into the future if future is true, and into the past otherwise. |
| public Period | |
| public Period | Returns: the new Periodtrue if the time is in the past past)Mark the duration as extending into the past if past is true, and into the future otherwise. |
| public boolean | Returns: true if this represents a duration into the future.Returns true if this represents a duration into the future. |
| public boolean | Returns: true if this represents a duration into the pastReturns true if this represents a duration into the past |
| public boolean | Returns: true if this represents a duration less than the defined duration.Returns true if this represents a duration less than the defined duration. |
| public boolean | Returns: true if this represents a duration in excess of the defined duration.Returns true if this represents a duration in excess of the defined duration. |
| public boolean | |
| public boolean | |
| public static Period | |
| public Period | |
| public static Period | |
| public Period | |
| public Period | |
| private Period | Returns: the new Periodtrue if the time is in the future future)Sets whether this defines a future time. |
| private Period | Returns: the new Periodthe kind of limit limit)Sets whether this is more than, less than, or 'about' the specified time. |
| private Period | Returns: the new Period object.the period to change unit, int the int value as described above. value)Sets the period to have the provided value, 1/1000 of the unit plus 1. |
| private Period | setTimeUnitValue(TimeUnit unit, float value)
Set the unit's internal value, converting from float to int. |
| counts | back to summary |
|---|---|
| pack-priv final int[] counts | |
| inFuture | back to summary |
|---|---|
| pack-priv final boolean inFuture | |
| timeLimit | back to summary |
|---|---|
| pack-priv final byte timeLimit | |
| Period | back to summary |
|---|---|
| private Period(int limit, boolean future, float count, TimeUnit unit) Private constructor used by static factory methods. | |
| Period | back to summary |
|---|---|
| pack-priv Period(int timeLimit, boolean inFuture, int[] counts) Package private constructor used by setters and factory. | |
| and | back to summary |
|---|---|
| public Period and(float count, TimeUnit unit) Set the given unit to have the given count. Marks the unit as having been set. This can be used to set multiple units, or to reset a unit to have a new count. This does not add the count to an existing count for this unit. | |
| at | back to summary |
|---|---|
| public static Period at(float count, TimeUnit unit) Constructs a Period representing a duration of count units extending into the past. | |
| at | back to summary |
|---|---|
| public Period at() Mark the duration as being at the defined duration.
| |
| checkCount | back to summary |
|---|---|
| private static void checkCount(float count) Validate count. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object rhs) Overrides java. Returns true if rhs extends Period and the two Periods are equal. | |
| equals | back to summary |
|---|---|
| public boolean equals(Period rhs) Returns true if the same units are defined with the same counts, both extend into the future or both into the past, and if the limits (at, more than, less than) are the same. Note that this means that a period of 1000ms and a period of 1sec will not compare equal.
| |
| getCount | back to summary |
|---|---|
| public float getCount(TimeUnit unit) Returns the count for the specified unit. If the unit is not set, returns 0.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hashCode.
| |
| inFuture | back to summary |
|---|---|
| public Period inFuture() Mark the time as being in the future.
| |
| inFuture | back to summary |
|---|---|
| public Period inFuture(boolean future) Mark the duration as extending into the future if future is true, and into the past otherwise.
| |
| inPast | back to summary |
|---|---|
| public Period inPast() Mark the duration as extending into the past.
| |
| inPast | back to summary |
|---|---|
| public Period inPast(boolean past) Mark the duration as extending into the past if past is true, and into the future otherwise.
| |
| isInFuture | back to summary |
|---|---|
| public boolean isInFuture() Returns true if this represents a duration into the future.
| |
| isInPast | back to summary |
|---|---|
| public boolean isInPast() Returns true if this represents a duration into the past
| |
| isLessThan | back to summary |
|---|---|
| public boolean isLessThan() Returns true if this represents a duration less than the defined duration.
| |
| isMoreThan | back to summary |
|---|---|
| public boolean isMoreThan() Returns true if this represents a duration in excess of the defined duration.
| |
| isSet | back to summary |
|---|---|
| public boolean isSet() Returns true if any unit is set.
| |
| isSet | back to summary |
|---|---|
| public boolean isSet(TimeUnit unit) Returns true if the given unit is set.
| |
| lessThan | back to summary |
|---|---|
| public static Period lessThan(float count, TimeUnit unit) Constructs a Period representing a duration less than count units extending into the past. | |
| lessThan | back to summary |
|---|---|
| public Period lessThan() Mark the duration as being less than the defined duration.
| |
| moreThan | back to summary |
|---|---|
| public static Period moreThan(float count, TimeUnit unit) Constructs a Period representing a duration more than count units extending into the past. | |
| moreThan | back to summary |
|---|---|
| public Period moreThan() Mark the duration as being more than the defined duration.
| |
| omit | back to summary |
|---|---|
| public Period omit(TimeUnit unit) Mark the given unit as not being set. | |
| setFuture | back to summary |
|---|---|
| private Period setFuture(boolean future) Sets whether this defines a future time.
| |
| setTimeLimit | back to summary |
|---|---|
| private Period setTimeLimit(byte limit) Sets whether this is more than, less than, or 'about' the specified time.
| |
| setTimeUnitInternalValue | back to summary |
|---|---|
| private Period setTimeUnitInternalValue(TimeUnit unit, int value) Sets the period to have the provided value, 1/1000 of the unit plus 1. Thus unset values are '0', 1' is the set value '0', 2 is the set value '1/1000', 3 is the set value '2/1000' etc. | |
| setTimeUnitValue | back to summary |
|---|---|
| private Period setTimeUnitValue(TimeUnit unit, float value) Set the unit's internal value, converting from float to int. | |