Modifier and Type | Field and Description |
---|---|
static Duration |
MaxValue
Represents the largest possible value of
Duration . |
static Duration |
MinValue
Represents the smallest possible value of
Duration . |
static long |
TicksPerDay
Represents the number of ticks in 1 day.
|
static long |
TicksPerHour
Represents the number of ticks in 1 hour.
|
static long |
TicksPerMillisecond
Represents the number of ticks in 1 millisecond.
|
static long |
TicksPerMinute
Represents the number of ticks in 1 minute.
|
static long |
TicksPerSecond
Represents the number of ticks in 1 second.
|
static Duration |
Zero
Represents zero duration.
|
Constructor and Description |
---|
Duration()
Initializes a new instance of the
Duration class with zero length. |
Duration(java.time.Duration duration)
Initializes a new instance of the
Duration class, storing specified java.time.Duration. |
Duration(int hours,
int minutes,
int seconds)
Initializes a new instance of the
Duration class with the specified duration. |
Duration(int days,
int hours,
int minutes,
int seconds)
Initializes a new instance of the
Duration class with the specified values. |
Duration(int days,
int hours,
int minutes,
int seconds,
int milliseconds)
Initializes a new instance of the
Duration class with the specified value. |
Duration(long ticks)
Initializes a new instance of the
Duration class with the specified length. |
Modifier and Type | Method and Description |
---|---|
Duration |
add(Duration duration)
|
Duration |
clone()
Cloneable.clone implementation. |
int |
compareTo(Duration o)
Comparable.compareTo implementation. |
boolean |
equals(java.lang.Object value)
Object.equals override. |
static Duration |
fromDays(double value)
Returns a
Duration that represents a specified number of days, where
the specification is accurate to the nearest millisecond. |
static Duration |
fromDays(long value)
Returns a
Duration that represents a specified number of days, where
the specification is accurate to the nearest millisecond. |
static Duration |
fromHours(double value)
Returns a
Duration that represents a specified number of hours, where
the specification is accurate to the nearest millisecond. |
static Duration |
fromHours(long value)
Returns a
Duration that represents a specified number of hours, where
the specification is accurate to the nearest millisecond. |
static Duration |
fromMilliseconds(double value)
Returns a
Duration that represents a specified number of milliseconds. |
static Duration |
fromMilliseconds(long value)
Returns a
Duration that represents a specified number of milliseconds. |
static Duration |
fromMinutes(double value)
Returns a
Duration that represents a specified number of minutes,
where the specification is accurate to the nearest millisecond. |
static Duration |
fromMinutes(long value)
Returns a
Duration that represents a specified number of minutes,
where the specification is accurate to the nearest millisecond. |
static Duration |
fromSeconds(double value)
Returns a
Duration that represents a specified number of seconds,
where the specification is accurate to the nearest millisecond. |
static Duration |
fromSeconds(long value)
Returns a
Duration that represents a specified number of seconds,
where the specification is accurate to the nearest millisecond. |
static Duration |
fromTicks(long value)
Returns a
Duration that represents a specified time, where the specification
is in units of ticks. |
int |
getDays()
Gets the days component of the time interval represented by the current
Duration object. |
int |
getHours()
Gets the hours component of the time interval represented by the current
Duration object. |
int |
getMilliseconds()
Gets the milliseconds component of the time interval represented by the current
Duration object. |
int |
getMinutes()
Gets the minutes component of the time interval represented by the current
Duration object. |
int |
getSeconds()
Gets the seconds component of the time interval represented by the current
Duration object. |
long |
getTicks()
Gets the number of ticks that represent the value of the current
Duration object. |
double |
getTotalDays()
Gets the value of the current
Duration object expressed in whole days. |
double |
getTotalHours()
Gets the value of the current
Duration expressed in whole and fractional hours. |
long |
getTotalMilliseconds()
Gets the total number of milliseconds in this instance.
|
double |
getTotalMinutes()
Gets the value of the current
Duration expressed in whole and fractional minutes. |
double |
getTotalSeconds()
Gets the value of the current
Duration object expressed in whole
and fractional seconds. |
int |
hashCode()
Object.hashCode override. |
Duration |
negate()
Returns a
Duration whose value is the negated value of the specified instance. |
static Duration |
op_Addition(Duration d1,
Duration d2)
Adds two specified
Duration instances. |
static boolean |
op_Equality(Duration d1,
Duration d2)
Indicates whether two
Duration instances are equal. |
static boolean |
op_GreaterThan(Duration d1,
Duration d2)
|
static boolean |
op_GreaterThanOrEqual(Duration d1,
Duration d2)
|
static boolean |
op_Inequality(Duration d1,
Duration d2)
Indicates whether two
Duration instances are not equal. |
static boolean |
op_LessThan(Duration d1,
Duration d2)
|
static boolean |
op_LessThanOrEqual(Duration d1,
Duration d2)
|
static Duration |
op_Subtraction(Duration d1,
Duration d2)
|
static Duration |
op_UnaryNegation(Duration d1)
Returns a
Duration whose value is the negated value of the specified instance. |
Duration |
subtract(Duration duration)
|
java.time.Duration |
toJavaDuration()
Returns the stored java.time.Duration.
|
java.lang.String |
toString()
Returns the string representation of the value of this instance.
|
public static final long TicksPerMillisecond
public static final long TicksPerSecond
public static final long TicksPerMinute
public static final long TicksPerHour
public static final long TicksPerDay
public static final Duration Zero
public Duration()
Duration
class with zero length.public Duration(java.time.Duration duration)
Duration
class, storing specified java.time.Duration.duration
- A java.time.Duration instance specifying duration.public Duration(long ticks)
Duration
class with the specified length.ticks
- A duration expressed in number of 100-nanosecond intervals.public Duration(int hours, int minutes, int seconds)
Duration
class with the specified duration.hours
- The hours component of the new duration.minutes
- The minutes component of the new duration.seconds
- The seconds component of the new duration.public Duration(int days, int hours, int minutes, int seconds)
Duration
class with the specified values.days
- The hours component of the new duration.hours
- The hours component of the new duration.minutes
- The minutes component of the new duration.seconds
- The seconds component of the new duration.public Duration(int days, int hours, int minutes, int seconds, int milliseconds)
Duration
class with the specified value.days
- The hours component of the new duration.hours
- The hours component of the new duration.minutes
- The minutes component of the new duration.seconds
- The seconds component of the new duration.milliseconds
- The milliseconds component of the new duration.public Duration clone()
Cloneable.clone
implementation.clone
in class java.lang.Object
Duration
object.public java.time.Duration toJavaDuration()
public int compareTo(Duration o)
Comparable.compareTo
implementation.public boolean equals(java.lang.Object value)
Object.equals
override.equals
in class java.lang.Object
value
- The object to compare to this instance.public int hashCode()
Object.hashCode
override.hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Duration
object.public static Duration fromTicks(long value)
Duration
that represents a specified time, where the specification
is in units of ticks.value
- A number of ticks that represent a time.Duration
with a value of value.public static Duration fromMilliseconds(double value)
Duration
that represents a specified number of milliseconds.value
- A number of milliseconds.Duration
that represents value.public static Duration fromMilliseconds(long value)
Duration
that represents a specified number of milliseconds.value
- A number of milliseconds.Duration
that represents value.public static Duration fromSeconds(double value)
Duration
that represents a specified number of seconds,
where the specification is accurate to the nearest millisecond.value
- A number of seconds, accurate to the nearest millisecond.Duration
that represents value.public static Duration fromSeconds(long value)
Duration
that represents a specified number of seconds,
where the specification is accurate to the nearest millisecond.value
- A number of seconds, accurate to the nearest millisecond.Duration
that represents value.public static Duration fromMinutes(double value)
Duration
that represents a specified number of minutes,
where the specification is accurate to the nearest millisecond.value
- A number of minutes, accurate to the nearest millisecond.Duration
that represents value.public static Duration fromMinutes(long value)
Duration
that represents a specified number of minutes,
where the specification is accurate to the nearest millisecond.value
- A number of minutes, accurate to the nearest millisecond.Duration
that represents value.public static Duration fromHours(double value)
Duration
that represents a specified number of hours, where
the specification is accurate to the nearest millisecond.value
- A number of hours accurate to the nearest millisecond.Duration
that represents value.public static Duration fromHours(long value)
Duration
that represents a specified number of hours, where
the specification is accurate to the nearest millisecond.value
- A number of hours accurate to the nearest millisecond.Duration
that represents value.public static Duration fromDays(double value)
Duration
that represents a specified number of days, where
the specification is accurate to the nearest millisecond.value
- A number of days, accurate to the nearest millisecond.Duration
that represents value.public static Duration fromDays(long value)
Duration
that represents a specified number of days, where
the specification is accurate to the nearest millisecond.value
- A number of days, accurate to the nearest millisecond.Duration
that represents value.public Duration add(Duration duration)
Duration
object whose value is the sum of the specified
Duration
object and this instance.duration
- A Duration
.java.lang.IllegalArgumentException
public Duration subtract(Duration duration)
Duration
object whose value is the difference between
the specified Duration
object and this instance.duration
- A Duration
.public Duration negate()
Duration
whose value is the negated value of the specified instance.Duration
with the same numeric value as this instance, but the opposite sign.public static Duration op_UnaryNegation(Duration d1)
Duration
whose value is the negated value of the specified instance.public static Duration op_Addition(Duration d1, Duration d2)
Duration
instances.public static boolean op_Equality(Duration d1, Duration d2)
Duration
instances are equal.public static boolean op_Inequality(Duration d1, Duration d2)
Duration
instances are not equal.public long getTicks()
Duration
object.public int getMilliseconds()
Duration
object.Duration
object.
The return value ranges from -999 through 999.public int getSeconds()
Duration
object.Duration
object.
The return value ranges from -59 through 59.public int getMinutes()
Duration
object.Duration
object.
The return value ranges from -59 through 59.public int getHours()
Duration
object.Duration
object.
The return value ranges from -23 through 23.public int getDays()
Duration
object.public long getTotalMilliseconds()
public double getTotalSeconds()
Duration
object expressed in whole
and fractional seconds.public double getTotalMinutes()
Duration
expressed in whole and fractional minutes.public double getTotalHours()
Duration
expressed in whole and fractional hours.public double getTotalDays()
Duration
object expressed in whole days.