Java Examples for java.time.temporal.TemporalUnit

The following java examples will help you to understand the usage of java.time.temporal.TemporalUnit. These source code samples are taken from different open source projects.

Example 1
Project: termd-master  File: Wait.java View source code
public static void forCondition(Supplier<Boolean> evaluationSupplier, long timeout, TemporalUnit timeUnit, String failedMessage) throws InterruptedException, TimeoutException {
    LocalDateTime started = LocalDateTime.now();
    while (true) {
        if (started.plus(timeout, timeUnit).isBefore(LocalDateTime.now())) {
            throw new TimeoutException(failedMessage + " Reached timeout " + timeout + " " + timeUnit);
        }
        if (evaluationSupplier.get()) {
            break;
        } else {
            Thread.sleep(100);
        }
    }
}
Example 2
Project: ProjectAres-master  File: TimeUtils.java View source code
public static long toUnit(TemporalUnit unit, Duration duration) {
    switch((ChronoUnit) unit) {
        case NANOS:
            return duration.toNanos();
        case MICROS:
            return toMicros(duration);
        case MILLIS:
            return duration.toMillis();
        case SECONDS:
            return duration.getSeconds();
    }
    if (unit.getDuration().getNano() == 0) {
        return duration.getSeconds() / unit.getDuration().getSeconds();
    }
    throw new IllegalArgumentException("Unsupported sub-second unit " + unit);
}
Example 3
Project: find-master  File: FindResult.java View source code
@SuppressWarnings("TypeMayBeWeakened")
private ZonedDateTime parseRelativeTime(final ZonedDateTime timeNow, final int timeAmount, final String timeUnit) {
    TemporalUnit temporalUnit = ChronoUnit.SECONDS;
    switch(timeUnit) {
        case "minute":
        case "minutes":
            temporalUnit = ChronoUnit.MINUTES;
            break;
        case "hour":
        case "hours":
            temporalUnit = ChronoUnit.HOURS;
            break;
        case "day":
        case "days":
            temporalUnit = ChronoUnit.DAYS;
            break;
        case "month":
        case "months":
            temporalUnit = ChronoUnit.MONTHS;
            break;
        case "year":
        case "years":
            temporalUnit = ChronoUnit.YEARS;
            break;
    }
    return timeNow.plus(timeAmount, temporalUnit);
}
Example 4
Project: ratpack-master  File: BlockingHttpClient.java View source code
public ReceivedResponse request(HttpClient httpClient, URI uri, ExecController execController, Duration timeout, Action<? super RequestSpec> action) throws Throwable {
    CountDownLatch latch = new CountDownLatch(1);
    AtomicReference<ExecResult<ReceivedResponse>> result = new AtomicReference<>();
    execController.fork().start( e -> httpClient.request(uri, action.prepend( s -> s.readTimeout(Duration.ofHours(1)))).map( response -> {
        TypedData responseBody = response.getBody();
        ByteBuf responseBuffer = responseBody.getBuffer();
        ByteBuf heapResponseBodyBuffer = unreleasableBuffer(responseBuffer.isDirect() ? TestByteBufAllocators.LEAKING_UNPOOLED_HEAP.heapBuffer(responseBuffer.readableBytes()).writeBytes(responseBuffer) : responseBuffer.retain());
        return new DefaultReceivedResponse(response.getStatus(), response.getHeaders(), new ByteBufBackedTypedData(heapResponseBodyBuffer, responseBody.getContentType()));
    }).connect(new Downstream<ReceivedResponse>() {

        @Override
        public void success(ReceivedResponse value) {
            result.set(ExecResult.of(Result.success(value)));
            latch.countDown();
        }

        @Override
        public void error(Throwable throwable) {
            result.set(ExecResult.of(Result.error(throwable)));
            latch.countDown();
        }

        @Override
        public void complete() {
            result.set(ExecResult.complete());
            latch.countDown();
        }
    }));
    try {
        if (!latch.await(timeout.toNanos(), TimeUnit.NANOSECONDS)) {
            TemporalUnit unit = timeout.getUnits().get(0);
            throw new IllegalStateException("Request to " + uri + " took more than " + timeout.get(unit) + " " + unit.toString() + " to complete");
        }
    } catch (InterruptedException e) {
        throw Exceptions.uncheck(e);
    }
    return result.get().getValueOrThrow();
}
Example 5
Project: javacuriosities-master  File: Lesson10TemporalPackage.java View source code
public static void main(String[] args) {
    LocalDate date = LocalDate.now();
    boolean isSupported = date.isSupported(ChronoField.HOUR_OF_DAY);
    System.out.println("LocalDate supports Hour of Day? " + isSupported);
    System.out.println("Date of month? " + date.get(ChronoField.DAY_OF_MONTH));
    System.out.println("Quarter of year? " + date.get(IsoFields.QUARTER_OF_YEAR));
    System.out.println("***Temporal Adjusters***");
    System.out.println("First day of Month: " + date.with(TemporalAdjusters.firstDayOfMonth()));
    System.out.println("First Monday of Month: " + date.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)));
    System.out.println("Last day of Month: " + date.with(TemporalAdjusters.lastDayOfMonth()));
    System.out.println("First day of next Month: " + date.with(TemporalAdjusters.firstDayOfNextMonth()));
    System.out.println("First day of next Year: " + date.with(TemporalAdjusters.firstDayOfNextYear()));
    System.out.println("First day of Year: " + date.with(TemporalAdjusters.firstDayOfYear()));
    System.out.println("***Custom Adjusters***");
    // Dado que "TemporalAdjuster" es una Functional Interface podes usar lambdas para definir nuestros propios adjusters
    System.out.println("Seven day of Month: " + date.with( t -> t.with(ChronoField.DAY_OF_MONTH, 7)));
    System.out.println("***Temporal Queries***");
    // Esta query retorna el "ChronoUnit" mas chico posible para el tipo solicitado
    TemporalQuery<TemporalUnit> query = TemporalQueries.precision();
    System.out.println("LocalDate precision is: " + LocalDate.now().query(query));
    System.out.println("LocalDateTime precision is: " + LocalDateTime.now().query(query));
    System.out.println("Year precision is: " + Year.now().query(query));
    System.out.println("YearMonth precision is: " + YearMonth.now().query(query));
    System.out.println("Instant precision is: " + Instant.now().query(query));
    System.out.println("Is Monday: " + LocalDate.now().query( t -> t.get(ChronoField.DAY_OF_WEEK) == DayOfWeek.MONDAY.getValue()));
}
Example 6
Project: janusgraph-master  File: ConsistentKeyLockerTest.java View source code
private LockInfo recordSuccessfulLockWrite(StoreTransaction tx, long duration, TemporalUnit tu, StaticBuffer del) throws BackendException {
    currentTimeNS = currentTimeNS.plusNanos(1);
    expect(times.getTime()).andReturn(currentTimeNS);
    final Instant lockNS = currentTimeNS;
    StaticBuffer lockCol = codec.toLockCol(lockNS, defaultLockRid, times);
    Entry add = StaticArrayEntry.of(lockCol, defaultLockVal);
    StaticBuffer k = eq(defaultLockKey);
    final List<Entry> adds = eq(Arrays.<Entry>asList(add));
    final List<StaticBuffer> dels;
    if (null != del) {
        dels = eq(Arrays.<StaticBuffer>asList(del));
    } else {
        dels = eq(ImmutableList.<StaticBuffer>of());
    }
    store.mutate(k, adds, dels, eq(tx));
    expectLastCall().once();
    currentTimeNS = currentTimeNS.plus(duration, tu);
    expect(times.getTime()).andReturn(currentTimeNS);
    ConsistentKeyLockStatus status = new ConsistentKeyLockStatus(lockNS, lockNS.plus(defaultExpireNS));
    return new LockInfo(lockNS, status, lockCol);
}
Example 7
Project: Time4J-master  File: DurationBasicsTest.java View source code
@Test
public void toTemporalAmount() {
    TemporalAmount ta1 = Duration.ofPositive().years(1).months(2).days(5).hours(10).millis(450).build().toTemporalAmount();
    assertThat(LocalDateTime.of(2016, 12, 31, 17, 0).plus(ta1), is(LocalDateTime.of(2018, 3, 6, 3, 0, 0, 450_000_000)));
    assertThat(LocalDateTime.of(2016, 12, 31, 17, 0).minus(ta1), is(LocalDateTime.of(2015, 10, 26, 6, 59, 59, 550_000_000)));
    TemporalAmount ta2 = Duration.ofNegative().years(1).months(2).days(5).hours(10).millis(450).build().toTemporalAmount();
    assertThat(LocalDateTime.of(2016, 12, 31, 17, 0).plus(ta2), is(LocalDateTime.of(2015, 10, 26, 6, 59, 59, 550_000_000)));
    assertThat(LocalDateTime.of(2016, 12, 31, 17, 0).minus(ta2), is(LocalDateTime.of(2018, 3, 6, 3, 0, 0, 450_000_000)));
    assertThat(ta1.get(ChronoUnit.MILLIS), is(450L));
    assertThat(ta2.get(ChronoUnit.MILLIS), is(-450L));
    List<TemporalUnit> expectedList = new ArrayList<>();
    expectedList.add(ChronoUnit.YEARS);
    expectedList.add(ChronoUnit.MONTHS);
    expectedList.add(ChronoUnit.DAYS);
    expectedList.add(ChronoUnit.HOURS);
    expectedList.add(ChronoUnit.NANOS);
    assertThat(ta1.getUnits(), is(expectedList));
}
Example 8
Project: tablesaw-master  File: DateMapUtils.java View source code
default DateColumn plus(int value, TemporalUnit unit) {
    DateColumn newColumn = DateColumn.create(dateColumnName(this, value, unit));
    DateColumn column1 = (DateColumn) this;
    for (int r = 0; r < column1.size(); r++) {
        Comparable c1 = column1.get(r);
        if (c1 == null) {
            newColumn.add(null);
        } else {
            LocalDate value1 = (LocalDate) c1;
            newColumn.add(value1.plus(value, unit));
        }
    }
    return newColumn;
}
Example 9
Project: Raildelays-master  File: TimeDelay.java View source code
/**
     * Create an an instance of {@link TimeDelay} with the {@code expectedTime} and the {@code delay}
     * of a certain {@code unit}.
     *
     * @param expectedTime the expected time such as : 1st January 2000 at 12:00
     * @param delay        delay in the {@code unit} counting from the {@code expectedTime}
     * @param unit         unit of the delay (unsupported units are {@code ChronoUnit.MICROS}, {@code ChronoUnit.NANOS}
     *                     and all not supported by {@link LocalTime#isSupported(TemporalUnit)})
     * @return a {@link TimeDelay} with the {@code expectedTime} and the {@code delay},
     * {@code null} if the {@code expectedTime} is {@code null}.
     * @throws UnsupportedTemporalTypeException if the unit is not supported
     */
public static TimeDelay of(LocalTime expectedTime, Long delay, TemporalUnit unit) {
    TimeDelay result = null;
    Objects.requireNonNull(unit);
    if (expectedTime != null) {
        Duration duration = Duration.of(DEFAULT_DELAY, DELAY_UNIT);
        if (delay != null) {
            if (!unit.isSupportedBy(expectedTime) || ChronoUnit.NANOS.equals(unit) || ChronoUnit.MICROS.equals(unit)) {
                throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
            }
            duration = Duration.of(delay, unit);
        }
        result = new TimeDelay(expectedTime, duration.toMillis());
    }
    return result;
}
Example 10
Project: business-hours-java-master  File: BusinessTemporal.java View source code
/**
     * Check that the given fields are contiguous and have a fixed length.
     *
     * @param supportedFields the fields
     */
private static void validateFields(SortedSet<ChronoField> fields) {
    TemporalUnit expectedBaseUnit = fields.first().getBaseUnit();
    for (ChronoField field : fields) {
        if (!field.getBaseUnit().equals(expectedBaseUnit)) {
            throw new DateTimeException("the fields must be contiguous");
        }
        if (!field.range().isFixed()) {
            throw new DateTimeException("the fields must have a fixed range");
        }
        expectedBaseUnit = field.getRangeUnit();
    }
}
Example 11
Project: error-prone-master  File: WellKnownMutability.java View source code
// TODO(b/35724557): share this list with other code analyzing types for immutability
// TODO(cushon): generate this at build-time to get type-safety without added compile-time deps
private static ImmutableMap<String, ImmutableAnnotationInfo> getBootstrapClasses() {
    return new Builder().addAll(Primitives.allPrimitiveTypes()).addAll(Primitives.allWrapperTypes()).add("com.google.protobuf.ByteString").add("com.google.protobuf.Descriptors$Descriptor").add("com.google.protobuf.Descriptors$EnumDescriptor").add("com.google.protobuf.Descriptors$EnumValueDescriptor").add("com.google.protobuf.Descriptors$FieldDescriptor").add("com.google.protobuf.Descriptors$FileDescriptor").add("com.google.protobuf.Descriptors$ServiceDescriptor").add("com.google.protobuf.Extension").add("com.google.protobuf.ExtensionRegistry$ExtensionInfo").add("com.google.re2j.Pattern").add(com.google.common.base.CharMatcher.class).add(com.google.common.base.Converter.class).add(com.google.common.base.Joiner.class).add(com.google.common.base.Optional.class, "T").add(com.google.common.base.Splitter.class).add(com.google.common.collect.ImmutableBiMap.class, "K", "V").add(com.google.common.collect.ImmutableCollection.class, "E").add(com.google.common.collect.ImmutableList.class, "E").add(com.google.common.collect.ImmutableListMultimap.class, "K", "V").add(com.google.common.collect.ImmutableMap.class, "K", "V").add(com.google.common.collect.ImmutableMultimap.class, "K", "V").add(com.google.common.collect.ImmutableMultiset.class, "E").add(com.google.common.collect.ImmutableRangeMap.class, "K", "V").add(com.google.common.collect.ImmutableRangeSet.class, "C").add(com.google.common.collect.ImmutableSet.class, "E").add(com.google.common.collect.ImmutableSetMultimap.class, "K", "V").add(com.google.common.collect.ImmutableSortedMap.class, "K", "V").add(com.google.common.collect.ImmutableSortedMultiset.class, "E").add(com.google.common.collect.ImmutableSortedSet.class, "E").add(com.google.common.collect.ImmutableTable.class, "R", "C", "V").add(com.google.common.collect.Range.class, "C").add(com.google.common.graph.ImmutableGraph.class, "N").add(com.google.common.graph.ImmutableNetwork.class, "N", "E").add(com.google.common.graph.ImmutableValueGraph.class, "N", "V").add(com.google.common.hash.HashCode.class).add(com.google.common.io.BaseEncoding.class).add(com.google.common.net.MediaType.class).add(com.google.common.primitives.UnsignedLong.class).add(java.lang.Class.class).add(java.lang.String.class).add(java.lang.annotation.Annotation.class).add(java.math.BigDecimal.class).add(java.math.BigInteger.class).add(java.net.InetAddress.class).add(java.net.URI.class).add(java.util.Locale.class).add(java.util.regex.Pattern.class).add("android.net.Uri").add("java.util.Optional", "T").add("java.time.Duration").add("java.time.Instant").add("java.time.LocalDate").add("java.time.LocalDateTime").add("java.time.LocalTime").add("java.time.MonthDay").add("java.time.OffsetDateTime").add("java.time.OffsetTime").add("java.time.Period").add("java.time.Year").add("java.time.YearMonth").add("java.time.ZoneId").add("java.time.ZoneOffset").add("java.time.ZonedDateTime").add("java.time.chrono.AbstractChronology").add("java.time.chrono.ChronoLocalDate").add("java.time.chrono.ChronoLocalDateTime", "D").add("java.time.chrono.ChronoPeriod").add("java.time.chrono.ChronoZonedDateTime", "D").add("java.time.chrono.Chronology").add("java.time.chrono.Era").add("java.time.chrono.HijrahChronology").add("java.time.chrono.HijrahDate").add("java.time.chrono.IsoChronology").add("java.time.chrono.JapaneseChronology").add("java.time.chrono.JapaneseDate").add("java.time.chrono.JapaneseEra").add("java.time.chrono.MinguoChronology").add("java.time.chrono.MinguoDate").add("java.time.chrono.ThaiBuddhistChronology").add("java.time.chrono.ThaiBuddhistDate").add("java.time.format.DateTimeFormatter").add("java.time.format.DecimalStyle").add("java.time.temporal.TemporalField").add("java.time.temporal.TemporalUnit").add("java.time.temporal.ValueRange").add("java.time.temporal.WeekFields").add("java.time.zone.ZoneOffsetTransition").add("java.time.zone.ZoneOffsetTransitionRule").add("java.time.zone.ZoneRules").add("java.time.zone.ZoneRulesProvider").add("org.joda.time.DateTime").add("org.joda.time.DateTimeZone").add("org.joda.time.Duration").add("org.joda.time.Instant").add("org.joda.time.LocalDate").add("org.joda.time.LocalDateTime").add("org.joda.time.Period").add("org.joda.time.format.DateTimeFormatter").build();
}
Example 12
Project: openjdk8-jdk-master  File: OffsetDateTime.java View source code
/**
     * Calculates the amount of time until another date-time in terms of the specified unit.
     * <p>
     * This calculates the amount of time between two {@code OffsetDateTime}
     * objects in terms of a single {@code TemporalUnit}.
     * The start and end points are {@code this} and the specified date-time.
     * The result will be negative if the end is before the start.
     * For example, the period in days between two date-times can be calculated
     * using {@code startDateTime.until(endDateTime, DAYS)}.
     * <p>
     * The {@code Temporal} passed to this method must be an {@code OffsetDateTime}.
     * If the offset differs between the two date-times, the specified
     * end date-time is normalized to have the same offset as this date-time.
     * <p>
     * The calculation returns a whole number, representing the number of
     * complete units between the two date-times.
     * For example, the period in months between 2012-06-15T00:00Z and 2012-08-14T23:59Z
     * will only be one month as it is one minute short of two months.
     * <p>
     * There are two equivalent ways of using this method.
     * The first is to invoke this method.
     * The second is to use {@link TemporalUnit#between(Temporal, Temporal)}:
     * <pre>
     *   // these two lines are equivalent
     *   amount = start.until(end, MONTHS);
     *   amount = MONTHS.between(start, end);
     * </pre>
     * The choice should be made based on which makes the code more readable.
     * <p>
     * The calculation is implemented in this method for {@link ChronoUnit}.
     * The units {@code NANOS}, {@code MICROS}, {@code MILLIS}, {@code SECONDS},
     * {@code MINUTES}, {@code HOURS} and {@code HALF_DAYS}, {@code DAYS},
     * {@code WEEKS}, {@code MONTHS}, {@code YEARS}, {@code DECADES},
     * {@code CENTURIES}, {@code MILLENNIA} and {@code ERAS} are supported.
     * Other {@code ChronoUnit} values will throw an exception.
     * <p>
     * If the unit is not a {@code ChronoUnit}, then the result of this method
     * is obtained by invoking {@code TemporalUnit.between(Temporal, Temporal)}
     * passing {@code this} as the first argument and the input temporal as
     * the second argument.
     * <p>
     * This instance is immutable and unaffected by this method call.
     *
     * @param endDateTime  the end date-time, which must be an {@code OffsetDateTime}, not null
     * @param unit  the unit to measure the amount in, not null
     * @return the amount of time between this date-time and the end date-time
     * @throws DateTimeException if the amount cannot be calculated
     * @throws UnsupportedTemporalTypeException if the unit is not supported
     * @throws ArithmeticException if numeric overflow occurs
     */
@Override
public long until(Temporal endDateTime, TemporalUnit unit) {
    if (endDateTime instanceof OffsetDateTime == false) {
        Objects.requireNonNull(endDateTime, "endDateTime");
        throw new DateTimeException("Unable to calculate amount as objects are of two different types");
    }
    if (unit instanceof ChronoUnit) {
        OffsetDateTime end = (OffsetDateTime) endDateTime;
        end = end.withOffsetSameInstant(offset);
        return dateTime.until(end.dateTime, unit);
    }
    return unit.between(this, endDateTime);
}
Example 13
Project: openjdk-master  File: ChronoLocalDateImpl.java View source code
//-----------------------------------------------------------------------
@Override
@SuppressWarnings("unchecked")
public D plus(long amountToAdd, TemporalUnit unit) {
    if (unit instanceof ChronoUnit) {
        ChronoUnit f = (ChronoUnit) unit;
        switch(f) {
            case DAYS:
                return plusDays(amountToAdd);
            case WEEKS:
                return plusDays(Math.multiplyExact(amountToAdd, 7));
            case MONTHS:
                return plusMonths(amountToAdd);
            case YEARS:
                return plusYears(amountToAdd);
            case DECADES:
                return plusYears(Math.multiplyExact(amountToAdd, 10));
            case CENTURIES:
                return plusYears(Math.multiplyExact(amountToAdd, 100));
            case MILLENNIA:
                return plusYears(Math.multiplyExact(amountToAdd, 1000));
            case ERAS:
                return with(ERA, Math.addExact(getLong(ERA), amountToAdd));
        }
        throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
    }
    return (D) ChronoLocalDate.super.plus(amountToAdd, unit);
}
Example 14
Project: optaplanner-master  File: TemporalValueRangeTest.java View source code
@Test
public void fullLocalDateRange() {
    TemporalUnit unit = ChronoUnit.DAYS;
    LocalDate from = LocalDate.MIN;
    LocalDate to = LocalDate.MAX;
    int increment = 4093;
    TemporalValueRange<LocalDate> range = new TemporalValueRange<>(from, to, increment, unit);
    assertEquals(from.until(to, unit), range.getSize() * increment);
    assertTrue(range.contains(from));
    assertFalse(range.contains(to));
}
Example 15
Project: jidefx-oss-master  File: PatternVerifierUtils.java View source code
private static void installForPatternVerifierField(ObservableMap<String, Callback<String, Boolean>> verifiers, String letter, int maxCount, boolean adjustable) {
    String pattern = letter;
    for (int i = 0; i < maxCount; i++) {
        TemporalField field = FIELD_MAP.get(letter.charAt(0));
        TemporalUnit unit = UNIT_MAP.get(letter.charAt(0));
        //            if (field == null || unit == null) {
        //                System.out.println(letter);
        //            }
        verifiers.put(pattern, adjustable ? new IntegerTemporalPatternVerifier(field, unit, pattern, pattern.length() != 1) : new IntegerTemporalPatternVerifierNotAdjustable(field, unit, pattern, pattern.length() != 1));
        pattern = pattern + letter;
    }
}
Example 16
Project: autopsy-master  File: ListTimeline.java View source code
@Override
public void accept(ActionEvent actionEvent) {
    ChronoField selectedChronoField = scrollInrementComboBox.getSelectionModel().getSelectedItem();
    ZoneId timeZoneID = TimeLineController.getTimeZoneID();
    TemporalUnit selectedUnit = selectedChronoField.getBaseUnit();
    int focusedIndex = table.getFocusModel().getFocusedIndex();
    CombinedEvent focusedItem = table.getFocusModel().getFocusedItem();
    if (-1 == focusedIndex || null == focusedItem) {
        focusedItem = visibleEvents.first();
        focusedIndex = table.getItems().indexOf(focusedItem);
    }
    ZonedDateTime focusedDateTime = Instant.ofEpochMilli(focusedItem.getStartMillis()).atZone(timeZoneID);
    //
    ZonedDateTime nextDateTime = focusedDateTime.plus(1, selectedUnit);
    for (ChronoField field : SCROLL_BY_UNITS) {
        if (field.getBaseUnit().getDuration().compareTo(selectedUnit.getDuration()) < 0) {
            //
            nextDateTime = nextDateTime.with(field, field.rangeRefinedBy(nextDateTime).getMinimum());
        }
    }
    long nextMillis = nextDateTime.toInstant().toEpochMilli();
    int nextIndex = table.getItems().size() - 1;
    for (int i = focusedIndex; i < table.getItems().size(); i++) {
        if (table.getItems().get(i).getStartMillis() >= nextMillis) {
            nextIndex = i;
            break;
        }
    }
    scrollToAndFocus(nextIndex);
}
Example 17
Project: edison-microservice-master  File: TestClock.java View source code
public void proceed(final long amount, final TemporalUnit unit) {
    current = current.plus(amount, unit);
}
Example 18
Project: hamcrest-jdk8-time-master  File: IsWithin.java View source code
public static Builder within(long window, TemporalUnit units) {
    return new Builder(window, units);
}
Example 19
Project: thingsboard-master  File: TsPartitionDate.java View source code
public TemporalUnit getTruncateUnit() {
    return truncateUnit;
}
Example 20
Project: assertj-core-master  File: TemporalUnitOffset.java View source code
public TemporalUnit getUnit() {
    return unit;
}
Example 21
Project: digipost-api-client-java-master  File: ListedTime.java View source code
@Override
public boolean isSupported(TemporalUnit unit) {
    return time.isSupported(unit);
}
Example 22
Project: EthiopianChronology-master  File: EthiopianDate.java View source code
@Override
public long until(Temporal endExclusive, TemporalUnit unit) {
    return getChronology().toGregorian(this).until(endExclusive, unit);
}
Example 23
Project: heron-master  File: CheckpointManagerConfigKey.java View source code
TemporalUnit getTemporalUnit() {
    return temporalUnit;
}
Example 24
Project: OG-Commons-master  File: Tenor.java View source code
//-------------------------------------------------------------------------
/**
   * Gets the value of the specified unit.
   * <p>
   * This will return a value for the years, months and days units.
   * Note that weeks are not included.
   * All other units throw an exception.
   * <p>
   * This method implements {@link TemporalAmount}.
   * It is not intended to be called directly.
   *
   * @param unit  the unit to query
   * @return the value of the unit
   * @throws UnsupportedTemporalTypeException if the unit is not supported
   */
@Override
public long get(TemporalUnit unit) {
    return period.get(unit);
}