Package org.pkl.core
Class Duration
java.lang.Object
org.pkl.core.Duration
- All Implemented Interfaces:
Serializable,Value
Java representation of a
pkl.base#Duration value.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDuration(double value, DurationUnit unit) Constructs a new duration with the given value and unit. -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(ValueConverter<T> converter) Invokes the given converters's convert method for thisValue.voidaccept(ValueVisitor visitor) Invokes the given visitor's visit method for thisValue.convertTo(DurationUnit other) Returns a new duration with the given unit and this value converted to the given unit.doubleconvertValueTo(DurationUnit other) Returns the value of this duration converted to the given unit.booleanPClassInfo<?> Returns information about the Pkl class associated with thisValue.getUnit()Returns the unit of this duration.doublegetValue()Returns the value of this duration.inthashCode()doubleinDays()Returns the value of this duration measured inDurationUnit.DAYS.doubleinHours()Returns the value of this duration measured inDurationUnit.HOURS.doubleinMicros()Returns the value of this duration measured inDurationUnit.MICROS.doubleinMillis()Returns the value of this duration measured inDurationUnit.MILLIS.doubleReturns the value of this duration measured inDurationUnit.MINUTES.doubleinNanos()Returns the value of this duration measured inDurationUnit.NANOS.doubleReturns the value of this duration measured inDurationUnit.SECONDS.longReturns the value of this duration measured in wholeDurationUnit.DAYS.longReturns the value of this duration measured in wholeDurationUnit.HOURS.longReturns the value of this duration measured in wholeDurationUnit.MICROS.longReturns the value of this duration measured in wholeDurationUnit.MILLIS.longReturns the value of this duration measured in wholeDurationUnit.MINUTES.longReturns the value of this duration measured in wholeDurationUnit.NANOS.longReturns the value of this duration measured in wholeDurationUnit.SECONDS.static DurationofDays(double value) Constructs a new duration with the given value and unitDurationUnit.DAYS.static DurationofHours(double value) Constructs a new duration with the given value and unitDurationUnit.HOURS.static DurationofMicros(double value) Constructs a new duration with the given value and unitDurationUnit.MICROS.static DurationofMillis(double value) Constructs a new duration with the given value and unitDurationUnit.MILLIS.static DurationofMinutes(double value) Constructs a new duration with the given value and unitDurationUnit.MINUTES.static DurationofNanos(double value) Constructs a new duration with the given value and unitDurationUnit.NANOS.static DurationofSeconds(double value) Constructs a new duration with the given value and unitDurationUnit.SECONDS.Returns an ISO 8601 representation of this duration.Converts this duration to aDuration.toString()
-
Constructor Details
-
Duration
Constructs a new duration with the given value and unit.
-
-
Method Details
-
ofNanos
Constructs a new duration with the given value and unitDurationUnit.NANOS. -
ofMicros
Constructs a new duration with the given value and unitDurationUnit.MICROS. -
ofMillis
Constructs a new duration with the given value and unitDurationUnit.MILLIS. -
ofSeconds
Constructs a new duration with the given value and unitDurationUnit.SECONDS. -
ofMinutes
Constructs a new duration with the given value and unitDurationUnit.MINUTES. -
ofHours
Constructs a new duration with the given value and unitDurationUnit.HOURS. -
ofDays
Constructs a new duration with the given value and unitDurationUnit.DAYS. -
getValue
public double getValue()Returns the value of this duration. The value is relative to the unit and may be negative. -
toIsoString
Returns an ISO 8601 representation of this duration. -
getUnit
Returns the unit of this duration. -
inNanos
public double inNanos()Returns the value of this duration measured inDurationUnit.NANOS. -
inMicros
public double inMicros()Returns the value of this duration measured inDurationUnit.MICROS. -
inMillis
public double inMillis()Returns the value of this duration measured inDurationUnit.MILLIS. -
inSeconds
public double inSeconds()Returns the value of this duration measured inDurationUnit.SECONDS. -
inMinutes
public double inMinutes()Returns the value of this duration measured inDurationUnit.MINUTES. -
inHours
public double inHours()Returns the value of this duration measured inDurationUnit.HOURS. -
inDays
public double inDays()Returns the value of this duration measured inDurationUnit.DAYS. -
inWholeNanos
public long inWholeNanos()Returns the value of this duration measured in wholeDurationUnit.NANOS. -
inWholeMicros
public long inWholeMicros()Returns the value of this duration measured in wholeDurationUnit.MICROS. -
inWholeMillis
public long inWholeMillis()Returns the value of this duration measured in wholeDurationUnit.MILLIS. -
inWholeSeconds
public long inWholeSeconds()Returns the value of this duration measured in wholeDurationUnit.SECONDS. -
inWholeMinutes
public long inWholeMinutes()Returns the value of this duration measured in wholeDurationUnit.MINUTES. -
inWholeHours
public long inWholeHours()Returns the value of this duration measured in wholeDurationUnit.HOURS. -
inWholeDays
public long inWholeDays()Returns the value of this duration measured in wholeDurationUnit.DAYS. -
toJavaDuration
Converts this duration to aDuration. IfgetValue()is NaN, +/-Infinity or too large to fit intoDuration,ArithmeticExceptionis thrown. -
convertTo
Returns a new duration with the given unit and this value converted to the given unit. -
convertValueTo
Returns the value of this duration converted to the given unit. -
accept
Invokes the given visitor's visit method for thisValue. -
accept
Invokes the given converters's convert method for thisValue. -
getClassInfo
Returns information about the Pkl class associated with thisValue.- Specified by:
getClassInfoin interfaceValue
-
equals
-
hashCode
public int hashCode() -
toString
-