Uses of Class
java.time.Duration

Packages that use Duration 
Package Description
java.lang
Provides classes that are fundamental to the design of the Java programming language.
java.net.http
HTTP Client and WebSocket APIs
java.time
The main API for dates, times, instants, and durations.
java.time.temporal
Access to date and time using fields and units, and date time adjusters.
java.time.zone
Support for time-zones and their rules.
java.util.concurrent
Utility classes commonly useful in concurrent programming.
jdk.jfr
This package provides classes to create events and control Flight Recorder.
jdk.jfr.consumer
This package contains classes for consuming Flight Recorder data.
  • Uses of Duration in java.lang

    Methods in java.lang that return types with arguments of type Duration 
    Modifier and Type Method Description
    Optional<Duration> ProcessHandle.Info.totalCpuDuration()
    Returns the total cputime accumulated of the process.
  • Uses of Duration in java.net.http

    Methods in java.net.http that return types with arguments of type Duration 
    Modifier and Type Method Description
    abstract Optional<Duration> HttpClient.connectTimeout()
    Returns an Optional containing the connect timeout duration for this client.
    abstract Optional<Duration> HttpRequest.timeout()
    Returns an Optional containing this request's timeout duration.
    Methods in java.net.http with parameters of type Duration 
    Modifier and Type Method Description
    HttpClient.Builder HttpClient.Builder.connectTimeout​(Duration duration)
    Sets the connect timeout duration for this client.
    WebSocket.Builder WebSocket.Builder.connectTimeout​(Duration timeout)
    Sets a timeout for establishing a WebSocket connection.
    HttpRequest.Builder HttpRequest.Builder.timeout​(Duration duration)
    Sets a timeout for this request.
  • Uses of Duration in java.time

    Fields in java.time declared as Duration 
    Modifier and Type Field Description
    static Duration Duration.ZERO
    Constant for a duration of zero.
    Methods in java.time that return Duration 
    Modifier and Type Method Description
    Duration Duration.abs()
    Returns a copy of this duration with a positive length.
    static Duration Duration.between​(Temporal startInclusive, Temporal endExclusive)
    Obtains a Duration representing the duration between two temporal objects.
    Duration Duration.dividedBy​(long divisor)
    Returns a copy of this duration divided by the specified value.
    static Duration Duration.from​(TemporalAmount amount)
    Obtains an instance of Duration from a temporal amount.
    Duration Duration.minus​(long amountToSubtract, TemporalUnit unit)
    Returns a copy of this duration with the specified duration subtracted.
    Duration Duration.minus​(Duration duration)
    Returns a copy of this duration with the specified duration subtracted.
    Duration Duration.minusDays​(long daysToSubtract)
    Returns a copy of this duration with the specified duration in standard 24 hour days subtracted.
    Duration Duration.minusHours​(long hoursToSubtract)
    Returns a copy of this duration with the specified duration in hours subtracted.
    Duration Duration.minusMillis​(long millisToSubtract)
    Returns a copy of this duration with the specified duration in milliseconds subtracted.
    Duration Duration.minusMinutes​(long minutesToSubtract)
    Returns a copy of this duration with the specified duration in minutes subtracted.
    Duration Duration.minusNanos​(long nanosToSubtract)
    Returns a copy of this duration with the specified duration in nanoseconds subtracted.
    Duration Duration.minusSeconds​(long secondsToSubtract)
    Returns a copy of this duration with the specified duration in seconds subtracted.
    Duration Duration.multipliedBy​(long multiplicand)
    Returns a copy of this duration multiplied by the scalar.
    Duration Duration.negated()
    Returns a copy of this duration with the length negated.
    static Duration Duration.of​(long amount, TemporalUnit unit)
    Obtains a Duration representing an amount in the specified unit.
    static Duration Duration.ofDays​(long days)
    Obtains a Duration representing a number of standard 24 hour days.
    static Duration Duration.ofHours​(long hours)
    Obtains a Duration representing a number of standard hours.
    static Duration Duration.ofMillis​(long millis)
    Obtains a Duration representing a number of milliseconds.
    static Duration Duration.ofMinutes​(long minutes)
    Obtains a Duration representing a number of standard minutes.
    static Duration Duration.ofNanos​(long nanos)
    Obtains a Duration representing a number of nanoseconds.
    static Duration Duration.ofSeconds​(long seconds)
    Obtains a Duration representing a number of seconds.
    static Duration Duration.ofSeconds​(long seconds, long nanoAdjustment)
    Obtains a Duration representing a number of seconds and an adjustment in nanoseconds.
    static Duration Duration.parse​(CharSequence text)
    Obtains a Duration from a text string such as PnDTnHnMn.nS.
    Duration Duration.plus​(long amountToAdd, TemporalUnit unit)
    Returns a copy of this duration with the specified duration added.
    Duration Duration.plus​(Duration duration)
    Returns a copy of this duration with the specified duration added.
    Duration Duration.plusDays​(long daysToAdd)
    Returns a copy of this duration with the specified duration in standard 24 hour days added.
    Duration Duration.plusHours​(long hoursToAdd)
    Returns a copy of this duration with the specified duration in hours added.
    Duration Duration.plusMillis​(long millisToAdd)
    Returns a copy of this duration with the specified duration in milliseconds added.
    Duration Duration.plusMinutes​(long minutesToAdd)
    Returns a copy of this duration with the specified duration in minutes added.
    Duration Duration.plusNanos​(long nanosToAdd)
    Returns a copy of this duration with the specified duration in nanoseconds added.
    Duration Duration.plusSeconds​(long secondsToAdd)
    Returns a copy of this duration with the specified duration in seconds added.
    Duration Duration.truncatedTo​(TemporalUnit unit)
    Returns a copy of this Duration truncated to the specified unit.
    Duration Duration.withNanos​(int nanoOfSecond)
    Returns a copy of this duration with the specified nano-of-second.
    Duration Duration.withSeconds​(long seconds)
    Returns a copy of this duration with the specified amount of seconds.
    Methods in java.time with parameters of type Duration 
    Modifier and Type Method Description
    int Duration.compareTo​(Duration otherDuration)
    Compares this duration to the specified Duration.
    long Duration.dividedBy​(Duration divisor)
    Returns number of whole times a specified Duration occurs within this Duration.
    Duration Duration.minus​(Duration duration)
    Returns a copy of this duration with the specified duration subtracted.
    static Clock Clock.offset​(Clock baseClock, Duration offsetDuration)
    Obtains a clock that returns instants from the specified clock with the specified duration added
    Duration Duration.plus​(Duration duration)
    Returns a copy of this duration with the specified duration added.
    static Clock Clock.tick​(Clock baseClock, Duration tickDuration)
    Obtains a clock that returns instants from the specified clock truncated to the nearest occurrence of the specified duration.
  • Uses of Duration in java.time.temporal

    Methods in java.time.temporal that return Duration 
    Modifier and Type Method Description
    Duration ChronoUnit.getDuration()
    Gets the estimated duration of this unit in the ISO calendar system.
    Duration TemporalUnit.getDuration()
    Gets the duration of this unit, which may be an estimate.
  • Uses of Duration in java.time.zone

    Methods in java.time.zone that return Duration 
    Modifier and Type Method Description
    Duration ZoneRules.getDaylightSavings​(Instant instant)
    Gets the amount of daylight savings in use for the specified instant in this zone.
    Duration ZoneOffsetTransition.getDuration()
    Gets the duration of the transition.
  • Uses of Duration in java.util.concurrent

    Methods in java.util.concurrent with parameters of type Duration 
    Modifier and Type Method Description
    long TimeUnit.convert​(Duration duration)
    Converts the given time duration to this unit.
  • Uses of Duration in jdk.jfr

    Methods in jdk.jfr that return Duration 
    Modifier and Type Method Description
    Duration Recording.getDuration()
    Returns the specified duration for this recording, or null if no duration is set.
    Duration Recording.getMaxAge()
    Returns the length of time that the data is kept in the disk repository before it is removed.
    Methods in jdk.jfr with parameters of type Duration 
    Modifier and Type Method Description
    void Recording.scheduleStart​(Duration delay)
    Starts this recording after a delay.
    void Recording.setDuration​(Duration duration)
    Sets a duration for how long a recording runs before it stops.
    void Recording.setMaxAge​(Duration maxAge)
    Determines how far back data is kept in the disk repository.
    EventSettings EventSettings.withPeriod​(Duration duration)
    Sets the interval for the event that is associated with this event setting.
    EventSettings EventSettings.withThreshold​(Duration duration)
    Sets the threshold for the event that is associated with this event setting.
  • Uses of Duration in jdk.jfr.consumer

    Methods in jdk.jfr.consumer that return Duration 
    Modifier and Type Method Description
    Duration RecordedEvent.getDuration()
    Returns the duration of the event, measured in nanoseconds.
    Duration RecordedObject.getDuration​(String name)
    Returns the value of a timespan field.