Home
last modified time | relevance | path

Searched refs:unit (Results 1 – 25 of 99) sorted by relevance

1234

/libcore/ojluni/src/test/java/time/test/java/time/
DMockSimplePeriod.java95 private final TemporalUnit unit; field in MockSimplePeriod
107 public static MockSimplePeriod of(long amount, TemporalUnit unit) { in of() argument
108 return new MockSimplePeriod(amount, unit); in of()
111 private MockSimplePeriod(long amount, TemporalUnit unit) { in MockSimplePeriod() argument
112 Objects.requireNonNull(unit, "unit"); in MockSimplePeriod()
113 if (unit == FOREVER) { in MockSimplePeriod()
117 this.unit = unit; in MockSimplePeriod()
121 public long get(TemporalUnit unit) { in get() argument
136 return unit; in getUnit()
142 return temporal.plus(amount, unit); in addTo()
[all …]
/libcore/ojluni/src/main/java/java/time/temporal/
DTemporal.java152 boolean isSupported(TemporalUnit unit); in isSupported() argument
297 Temporal plus(long amountToAdd, TemporalUnit unit); in plus() argument
369 default Temporal minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
370 …oSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, u… in minus()
447 long until(Temporal endExclusive, TemporalUnit unit); in until() argument
/libcore/ojluni/src/main/java/java/nio/file/attribute/
DFileTime.java57 private final TimeUnit unit; field in FileTime
77 private FileTime(long value, TimeUnit unit, Instant instant) { in FileTime() argument
79 this.unit = unit; in FileTime()
95 public static FileTime from(long value, TimeUnit unit) { in from() argument
96 Objects.requireNonNull(unit, "unit"); in from()
97 return new FileTime(value, unit, null); in from()
141 public long to(TimeUnit unit) { in to() argument
142 Objects.requireNonNull(unit, "unit"); in to()
143 if (this.unit != null) { in to()
144 return unit.convert(this.value, this.unit); in to()
[all …]
/libcore/ojluni/src/main/java/java/time/
DYear.java396 public boolean isSupported(TemporalUnit unit) { in isSupported() argument
397 if (unit instanceof ChronoUnit) { in isSupported()
398 … return unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNIA || unit == ERAS; in isSupported()
400 return unit != null && unit.isSupportedBy(this); in isSupported()
702 public Year plus(long amountToAdd, TemporalUnit unit) { in plus() argument
703 if (unit instanceof ChronoUnit) { in plus()
704 switch ((ChronoUnit) unit) { in plus()
711 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); in plus()
713 return unit.addTo(this, amountToAdd); in plus()
778 public Year minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
[all …]
DYearMonth.java384 public boolean isSupported(TemporalUnit unit) { in isSupported() argument
385 if (unit instanceof ChronoUnit) { in isSupported()
386 …return unit == MONTHS || unit == YEARS || unit == DECADES || unit == CENTURIES || unit == MILLENNI… in isSupported()
388 return unit != null && unit.isSupportedBy(this); in isSupported()
799 public YearMonth plus(long amountToAdd, TemporalUnit unit) { in plus() argument
800 if (unit instanceof ChronoUnit) { in plus()
801 switch ((ChronoUnit) unit) { in plus()
809 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); in plus()
811 return unit.addTo(this, amountToAdd); in plus()
897 public YearMonth minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
[all …]
DInstant.java488 public boolean isSupported(TemporalUnit unit) { in isSupported() argument
489 if (unit instanceof ChronoUnit) { in isSupported()
490 return unit.isTimeBased() || unit == DAYS; in isSupported()
492 return unit != null && unit.isSupportedBy(this); in isSupported()
742 public Instant truncatedTo(TemporalUnit unit) { in truncatedTo() argument
743 if (unit == ChronoUnit.NANOS) { in truncatedTo()
746 Duration unitDur = unit.getDuration(); in truncatedTo()
844 public Instant plus(long amountToAdd, TemporalUnit unit) { in plus() argument
845 if (unit instanceof ChronoUnit) { in plus()
846 switch ((ChronoUnit) unit) { in plus()
[all …]
DDuration.java303 public static Duration of(long amount, TemporalUnit unit) { in of() argument
304 return ZERO.plus(amount, unit); in of()
331 for (TemporalUnit unit : amount.getUnits()) { in from()
332 duration = duration.plus(amount.get(unit), unit); in from()
527 public long get(TemporalUnit unit) { in get() argument
528 if (unit == SECONDS) { in get()
530 } else if (unit == NANOS) { in get()
533 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); in get()
691 public Duration plus(long amountToAdd, TemporalUnit unit) { in plus() argument
692 Objects.requireNonNull(unit, "unit"); in plus()
[all …]
DLocalTime.java570 public boolean isSupported(TemporalUnit unit) { in isSupported() argument
571 if (unit instanceof ChronoUnit) { in isSupported()
572 return unit.isTimeBased(); in isSupported()
574 return unit != null && unit.isSupportedBy(this); in isSupported()
966 public LocalTime truncatedTo(TemporalUnit unit) { in truncatedTo() argument
967 if (unit == ChronoUnit.NANOS) { in truncatedTo()
970 Duration unitDur = unit.getDuration(); in truncatedTo()
1061 public LocalTime plus(long amountToAdd, TemporalUnit unit) { in plus() argument
1062 if (unit instanceof ChronoUnit) { in plus()
1063 switch ((ChronoUnit) unit) { in plus()
[all …]
DOffsetDateTime.java519 public boolean isSupported(TemporalUnit unit) { in isSupported() argument
520 if (unit instanceof ChronoUnit) { in isSupported()
521 return unit != FOREVER; in isSupported()
523 return unit != null && unit.isSupportedBy(this); in isSupported()
1126 public OffsetDateTime truncatedTo(TemporalUnit unit) { in truncatedTo() argument
1127 return with(dateTime.truncatedTo(unit), offset); in truncatedTo()
1182 public OffsetDateTime plus(long amountToAdd, TemporalUnit unit) { in plus() argument
1183 if (unit instanceof ChronoUnit) { in plus()
1184 return with(dateTime.plus(amountToAdd, unit), offset); in plus()
1186 return unit.addTo(this, amountToAdd); in plus()
[all …]
DLocalDateTime.java613 public boolean isSupported(TemporalUnit unit) { in isSupported() argument
614 return ChronoLocalDateTime.super.isSupported(unit); in isSupported()
1114 public LocalDateTime truncatedTo(TemporalUnit unit) { in truncatedTo() argument
1115 return with(date, time.truncatedTo(unit)); in truncatedTo()
1176 public LocalDateTime plus(long amountToAdd, TemporalUnit unit) { in plus() argument
1177 if (unit instanceof ChronoUnit) { in plus()
1178 ChronoUnit f = (ChronoUnit) unit; in plus()
1188 return with(date.plus(amountToAdd, unit), time); in plus()
1190 return unit.addTo(this, amountToAdd); in plus()
1388 public LocalDateTime minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
[all …]
/libcore/ojluni/src/main/java/java/util/concurrent/
DScheduledExecutorService.java111 long delay, TimeUnit unit); in schedule() argument
127 long delay, TimeUnit unit); in schedule() argument
171 TimeUnit unit); in scheduleAtFixedRate() argument
211 TimeUnit unit); in scheduleWithFixedDelay() argument
DBlockingDeque.java324 boolean offerFirst(E e, long timeout, TimeUnit unit) in offerFirst() argument
346 boolean offerLast(E e, long timeout, TimeUnit unit) in offerLast() argument
380 E pollFirst(long timeout, TimeUnit unit) in pollFirst() argument
396 E pollLast(long timeout, TimeUnit unit) in pollLast() argument
513 boolean offer(E e, long timeout, TimeUnit unit) in offer() argument
564 E poll(long timeout, TimeUnit unit) in poll() argument
DExecutors.java635 public boolean awaitTermination(long timeout, TimeUnit unit)
637 return e.awaitTermination(timeout, unit);
653 long timeout, TimeUnit unit)
655 return e.invokeAll(tasks, timeout, unit);
662 long timeout, TimeUnit unit)
664 return e.invokeAny(tasks, timeout, unit);
690 public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
691 return e.schedule(command, delay, unit);
693 public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
694 return e.schedule(callable, delay, unit);
[all …]
DScheduledThreadPoolExecutor.java240 public long getDelay(TimeUnit unit) { in getDelay() argument
241 return unit.convert(time - System.nanoTime(), NANOSECONDS); in getDelay()
520 private long triggerTime(long delay, TimeUnit unit) { in triggerTime() argument
521 return triggerTime(unit.toNanos((delay < 0) ? 0 : delay)); in triggerTime()
555 TimeUnit unit) { in schedule() argument
556 if (command == null || unit == null) in schedule()
560 triggerTime(delay, unit), in schedule()
572 TimeUnit unit) { in schedule() argument
573 if (callable == null || unit == null) in schedule()
577 triggerTime(delay, unit), in schedule()
[all …]
/libcore/luni/src/test/java/libcore/java/time/
DOffsetTimeTest.java70 private static void assertPlusIsNoop(long amount, TemporalUnit unit) { in assertPlusIsNoop() argument
71 assertSame(NOON_UTC, NOON_UTC.plus(amount, unit)); in assertPlusIsNoop()
76 for (ChronoUnit unit : EnumSet.range(ChronoUnit.DAYS, ChronoUnit.FOREVER)) { in test_plus_minus_invalidUnits()
78 NOON_UTC.plus(1, unit); in test_plus_minus_invalidUnits()
79 fail("Adding 1 " + unit + " should have failed."); in test_plus_minus_invalidUnits()
83 NOON_UTC.minus(1, unit); in test_plus_minus_invalidUnits()
84 fail("Subtracting 1 " + unit + " should have failed."); in test_plus_minus_invalidUnits()
/libcore/ojluni/src/main/java/java/time/chrono/
DChronoLocalDate.java409 default boolean isSupported(TemporalUnit unit) { in isSupported() argument
410 if (unit instanceof ChronoUnit) { in isSupported()
411 return unit.isDateBased(); in isSupported()
413 return unit != null && unit.isSupportedBy(this); in isSupported()
458 default ChronoLocalDate plus(long amountToAdd, TemporalUnit unit) { in plus() argument
459 if (unit instanceof ChronoUnit) { in plus()
460 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); in plus()
462 return ChronoLocalDateImpl.ensureValid(getChronology(), unit.addTo(this, amountToAdd)); in plus()
482 default ChronoLocalDate minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
483 …urn ChronoLocalDateImpl.ensureValid(getChronology(), Temporal.super.minus(amountToSubtract, unit)); in minus()
[all …]
DChronoLocalDateImpl.java198 public D plus(long amountToAdd, TemporalUnit unit) { in plus() argument
199 if (unit instanceof ChronoUnit) { in plus()
200 ChronoUnit f = (ChronoUnit) unit; in plus()
211 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); in plus()
213 return (D) ChronoLocalDate.super.plus(amountToAdd, unit); in plus()
224 public D minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
225 return (D) ChronoLocalDate.super.minus(amountToSubtract, unit); in minus()
376 public long until(Temporal endExclusive, TemporalUnit unit) { in until() argument
379 if (unit instanceof ChronoUnit) { in until()
380 switch ((ChronoUnit) unit) { in until()
[all …]
DChronoPeriod.java137 long get(TemporalUnit unit); in get() argument
173 for (TemporalUnit unit : getUnits()) { in isZero()
174 if (get(unit) != 0) { in isZero()
187 for (TemporalUnit unit : getUnits()) { in isNegative()
188 if (get(unit) < 0) { in isNegative()
DChronoLocalDateTimeImpl.java304 public ChronoLocalDateTimeImpl<D> plus(long amountToAdd, TemporalUnit unit) { in plus() argument
305 if (unit instanceof ChronoUnit) { in plus()
306 ChronoUnit f = (ChronoUnit) unit; in plus()
316 return with(date.plus(amountToAdd, unit), time); in plus()
318 … return ChronoLocalDateTimeImpl.ensureValid(date.getChronology(), unit.addTo(this, amountToAdd)); in plus()
371 public long until(Temporal endExclusive, TemporalUnit unit) { in until() argument
375 if (unit instanceof ChronoUnit) { in until()
376 if (unit.isTimeBased()) { in until()
378 switch ((ChronoUnit) unit) { in until()
387 return Math.addExact(amount, time.until(end.toLocalTime(), unit)); in until()
[all …]
DChronoLocalDateTime.java250 default boolean isSupported(TemporalUnit unit) { in isSupported() argument
251 if (unit instanceof ChronoUnit) { in isSupported()
252 return unit != FOREVER; in isSupported()
254 return unit != null && unit.isSupportedBy(this); in isSupported()
293 ChronoLocalDateTime<D> plus(long amountToAdd, TemporalUnit unit); in plus() argument
311 default ChronoLocalDateTime<D> minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
312 …ChronoLocalDateTimeImpl.ensureValid(getChronology(), Temporal.super.minus(amountToSubtract, unit)); in minus()
DChronoZonedDateTime.java397 default boolean isSupported(TemporalUnit unit) { in isSupported() argument
398 if (unit instanceof ChronoUnit) { in isSupported()
399 return unit != FOREVER; in isSupported()
401 return unit != null && unit.isSupportedBy(this); in isSupported()
440 ChronoZonedDateTime<D> plus(long amountToAdd, TemporalUnit unit); in plus() argument
458 default ChronoZonedDateTime<D> minus(long amountToSubtract, TemporalUnit unit) { in minus() argument
459 …ChronoZonedDateTimeImpl.ensureValid(getChronology(), Temporal.super.minus(amountToSubtract, unit)); in minus()
/libcore/ojluni/src/test/java/time/tck/java/time/temporal/
DTCKChronoUnit.java123 …public void test_unitType(ChronoUnit unit, boolean isDateBased, boolean isTimeBased, boolean isDur… in test_unitType() argument
124 assertEquals(unit.isDateBased(), isDateBased); in test_unitType()
125 assertEquals(unit.isTimeBased(), isTimeBased); in test_unitType()
126 assertEquals(unit.isDurationEstimated(), isDurationEstimated); in test_unitType()
169 …public void test_unitAndTemporal(ChronoUnit unit, Temporal base, boolean isSupportedBy, long amoun… in test_unitAndTemporal() argument
170 assertEquals(unit.isSupportedBy(base), isSupportedBy); in test_unitAndTemporal()
172 Temporal result = unit.addTo(base, amount); in test_unitAndTemporal()
174 assertEquals(unit.between(base, result), amount); in test_unitAndTemporal()
183 for (ChronoUnit unit : ChronoUnit.values()) { in test_valueOf()
184 assertEquals(ChronoUnit.valueOf(unit.name()), unit); in test_valueOf() local
/libcore/ojluni/src/main/java/java/lang/
DProcess.java186 public boolean waitFor(long timeout, TimeUnit unit) in waitFor() argument
190 long rem = unit.toNanos(timeout); in waitFor()
201 rem = unit.toNanos(timeout) - (System.nanoTime() - startTime); in waitFor()
/libcore/ojluni/src/main/java/sun/nio/ch/
DAsynchronousSocketChannelImpl.java219 TimeUnit unit, in implRead() argument
228 TimeUnit unit, in read() argument
276 return implRead(isScatteringRead, dst, dsts, timeout, unit, att, handler); in read()
289 TimeUnit unit, in read() argument
297 read(false, dst, null, timeout, unit, attachment, handler); in read()
305 TimeUnit unit, in read() argument
318 read(true, null, bufs, timeout, unit, attachment, handler); in read()
328 TimeUnit unit, in implWrite() argument
337 TimeUnit unit, in write() argument
382 return implWrite(isGatheringWrite, src, srcs, timeout, unit, att, handler); in write()
[all …]
/libcore/ojluni/src/test/java/time/tck/java/time/chrono/
DCopticDate.java259 public CopticDate plus(long amountToAdd, TemporalUnit unit) { in plus() argument
260 if (unit instanceof ChronoUnit) { in plus()
261 ChronoUnit f = (ChronoUnit) unit; in plus()
271 throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit); in plus()
273 return unit.addTo(this, amountToAdd); in plus()
300 public long until(Temporal endExclusive, TemporalUnit unit) { in until() argument
302 if (unit instanceof ChronoUnit) { in until()
303 return LocalDate.from(this).until(end, unit); // TODO: this is wrong in until()
305 return unit.between(this, end); in until()

1234