Home | History | Annotate | Download | only in time

Lines Matching refs:unit

74  * Mock period of time measured using a single unit, such as {@code 3 Days}.
93 * The unit the period is measured in.
95 private final TemporalUnit unit;
98 * Obtains a {@code MockSimplePeriod} from an amount and unit.
102 * @param amount the amount of the period, measured in terms of the unit, positive or negative
103 * @param unit the unit that the period is measured in, must not be the 'Forever' unit, not null
105 * @throws DateTimeException if the period unit is {@link java.time.temporal.ChronoUnit#FOREVER}.
107 public static MockSimplePeriod of(long amount, TemporalUnit unit) {
108 return new MockSimplePeriod(amount, unit);
111 private MockSimplePeriod(long amount, TemporalUnit unit) {
112 Objects.requireNonNull(unit, "unit");
113 if (unit == FOREVER) {
114 throw new DateTimeException("Cannot create a period of the Forever unit");
117 this.unit = unit;
121 public long get(TemporalUnit unit) {
136 return unit;
142 return temporal.plus(amount, unit);
147 return temporal.minus(amount, unit);
153 if (unit.equals(otherPeriod.getUnit()) == false) {
154 throw new IllegalArgumentException("Units cannot be compared: " + unit + " and " + otherPeriod.getUnit());
167 this.unit.equals(other.unit);
174 return unit.hashCode() ^ (int) (amount ^ (amount >>> 32));
179 return amount + " " + unit;