Uses of Class
java.time.Duration
Package
Description
Provides classes that are fundamental to the design of the Java
programming language.
HTTP Client and WebSocket APIs
The main API for dates, times, instants, and durations.
Access to date and time using fields and units, and date time adjusters.
Support for time-zones and their rules.
Utility classes commonly useful in concurrent programming.
This package provides classes to create events and control Flight Recorder.
This package contains classes for consuming Flight Recorder data.
This package contains classes to control and monitor Flight Recorder over Java Management Extensions (JMX).
-
Uses of Duration in java.lang
Modifier and TypeMethodDescriptionProcessHandle.Info.totalCpuDuration()
Returns the total cputime accumulated of the process. -
Uses of Duration in java.net.http
Modifier and TypeMethodDescriptionHttpClient.connectTimeout()
Returns anOptional
containing the connect timeout duration for this client.HttpRequest.timeout()
Returns anOptional
containing this request's timeout duration.Modifier and TypeMethodDescriptionHttpClient.Builder.connectTimeout(Duration duration)
Sets the connect timeout duration for this client.WebSocket.Builder.connectTimeout(Duration timeout)
Sets a timeout for establishing a WebSocket connection.Sets a timeout for this request. -
Uses of Duration in java.time
Modifier and TypeMethodDescriptionDuration.abs()
Returns a copy of this duration with a positive length.static Duration
Obtains aDuration
representing the duration between two temporal objects.Duration.dividedBy(long divisor)
Returns a copy of this duration divided by the specified value.static Duration
Duration.from(TemporalAmount amount)
Obtains an instance ofDuration
from a temporal amount.Duration.minus(long amountToSubtract, TemporalUnit unit)
Returns a copy of this duration with the specified duration subtracted.Returns a copy of this duration with the specified duration subtracted.Duration.minusDays(long daysToSubtract)
Returns a copy of this duration with the specified duration in standard 24 hour days subtracted.Duration.minusHours(long hoursToSubtract)
Returns a copy of this duration with the specified duration in hours subtracted.Duration.minusMillis(long millisToSubtract)
Returns a copy of this duration with the specified duration in milliseconds subtracted.Duration.minusMinutes(long minutesToSubtract)
Returns a copy of this duration with the specified duration in minutes subtracted.Duration.minusNanos(long nanosToSubtract)
Returns a copy of this duration with the specified duration in nanoseconds subtracted.Duration.minusSeconds(long secondsToSubtract)
Returns a copy of this duration with the specified duration in seconds subtracted.Duration.multipliedBy(long multiplicand)
Returns a copy of this duration multiplied by the scalar.Duration.negated()
Returns a copy of this duration with the length negated.static Duration
Duration.of(long amount, TemporalUnit unit)
Obtains aDuration
representing an amount in the specified unit.static Duration
Duration.ofDays(long days)
Obtains aDuration
representing a number of standard 24 hour days.static Duration
Duration.ofHours(long hours)
Obtains aDuration
representing a number of standard hours.static Duration
Duration.ofMillis(long millis)
Obtains aDuration
representing a number of milliseconds.static Duration
Duration.ofMinutes(long minutes)
Obtains aDuration
representing a number of standard minutes.static Duration
Duration.ofNanos(long nanos)
Obtains aDuration
representing a number of nanoseconds.static Duration
Duration.ofSeconds(long seconds)
Obtains aDuration
representing a number of seconds.static Duration
Duration.ofSeconds(long seconds, long nanoAdjustment)
Obtains aDuration
representing a number of seconds and an adjustment in nanoseconds.static Duration
Duration.parse(CharSequence text)
Obtains aDuration
from a text string such asPnDTnHnMn.nS
.Duration.plus(long amountToAdd, TemporalUnit unit)
Returns a copy of this duration with the specified duration added.Returns a copy of this duration with the specified duration added.Duration.plusDays(long daysToAdd)
Returns a copy of this duration with the specified duration in standard 24 hour days added.Duration.plusHours(long hoursToAdd)
Returns a copy of this duration with the specified duration in hours added.Duration.plusMillis(long millisToAdd)
Returns a copy of this duration with the specified duration in milliseconds added.Duration.plusMinutes(long minutesToAdd)
Returns a copy of this duration with the specified duration in minutes added.Duration.plusNanos(long nanosToAdd)
Returns a copy of this duration with the specified duration in nanoseconds added.Duration.plusSeconds(long secondsToAdd)
Returns a copy of this duration with the specified duration in seconds added.Duration.truncatedTo(TemporalUnit unit)
Returns a copy of thisDuration
truncated to the specified unit.Duration.withNanos(int nanoOfSecond)
Returns a copy of this duration with the specified nano-of-second.Duration.withSeconds(long seconds)
Returns a copy of this duration with the specified amount of seconds.Modifier and TypeMethodDescriptionint
Compares this duration to the specifiedDuration
.long
Returns number of whole times a specified Duration occurs within this Duration.Returns a copy of this duration with the specified duration subtracted.static Clock
Obtains a clock that returns instants from the specified clock with the specified duration addedReturns a copy of this duration with the specified duration added.static Clock
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
Modifier and TypeMethodDescriptionChronoUnit.getDuration()
Gets the estimated duration of this unit in the ISO calendar system.TemporalUnit.getDuration()
Gets the duration of this unit, which may be an estimate. -
Uses of Duration in java.time.zone
Modifier and TypeMethodDescriptionZoneRules.getDaylightSavings(Instant instant)
Gets the amount of daylight savings in use for the specified instant in this zone.ZoneOffsetTransition.getDuration()
Gets the duration of the transition. -
Uses of Duration in java.util.concurrent
-
Uses of Duration in jdk.jfr
Modifier and TypeMethodDescriptionRecording.getDuration()
Returns the specified duration for this recording, ornull
if no duration is set.Recording.getMaxAge()
Returns the length of time that the data is kept in the disk repository before it is removed.Modifier and TypeMethodDescriptionvoid
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
Determines how far back data is kept in the disk repository.EventSettings.withPeriod(Duration duration)
Sets the interval for the event that is associated with this event setting.EventSettings.withThreshold(Duration duration)
Sets the threshold for the event that is associated with this event setting. -
Uses of Duration in jdk.jfr.consumer
Modifier and TypeMethodDescriptionRecordedEvent.getDuration()
Returns the duration of the event, measured in nanoseconds.RecordedObject.getDuration(String name)
Returns the value of a timespan field.Modifier and TypeMethodDescriptionvoid
EventStream.awaitTermination(Duration timeout)
Blocks until all actions are completed, or the stream is closed, or the timeout occurs, or the current thread is interrupted, whichever happens first.void
RecordingStream.awaitTermination(Duration timeout)
void
Determines how far back data is kept for the stream. -
Uses of Duration in jdk.management.jfr
Modifier and TypeMethodDescriptionvoid
RemoteRecordingStream.awaitTermination(Duration timeout)
void
Determines how far back data is kept for the stream.