public class DefaultDuration extends AbstractCloneableSerializable implements Duration
Duration
interface. It is implemented
storing milliseconds as a double value.Modifier and Type | Field and Description |
---|---|
static DefaultDuration |
DAY
A day in duration.
|
static DefaultDuration |
HOUR
An hour in duration.
|
static int |
HOURS_PER_DAY
There are 24 hours per day.
|
static DefaultDuration |
MAX_VALUE
The maximum value of a duration.
|
static DefaultDuration |
MILLISECOND
A millisecond in duration.
|
static int |
MILLISECONDS_PER_DAY
There are 86400000 milliseoncds per day.
|
static int |
MILLISECONDS_PER_HOUR
There are 3600000 milliseconds per hour.
|
static int |
MILLISECONDS_PER_MINUTE
There are 60000 milliseconds per minute.
|
static int |
MILLISECONDS_PER_SECOND
There are 1000 milliseconds per second.
|
static DefaultDuration |
MIN_VALUE
The minimum value of a duration.
|
static DefaultDuration |
MINUTE
A minute in duration.
|
static int |
MINUTES_PER_HOUR
There are 60 minutes per hour.
|
static DefaultDuration |
SECOND
A second in duration.
|
static int |
SECONDS_PER_MINUTE
There are 60 seconds per minute.
|
static java.text.DecimalFormat |
THREE_DIGIT_FORMAT
Formatting used for the toString method that creates numbers of three
digits.
|
static DefaultDuration |
ZERO
A zero duration.
|
Modifier | Constructor and Description |
---|---|
protected |
DefaultDuration(double milliseconds)
Creates a new
DefaultDuration representing the given number of
milliseconds. |
Modifier and Type | Method and Description |
---|---|
Duration |
absoluteValue()
Returns the absolute value of this duration.
|
int |
compareTo(Duration other) |
Duration |
divide(double scalar)
Divides this duration by the given scalar value and returns the result.
|
double |
divide(Duration other)
Divides this duration by the given duration and returns the ratio.
|
boolean |
equals(Duration other)
Determines if this duration is equivalent to the given duration.
|
boolean |
equals(java.lang.Object other) |
static DefaultDuration |
fromDays(double days)
Creates a new
DefaultDuration from the given number of
days. |
static DefaultDuration |
fromHours(double hours)
Creates a new
DefaultDuration from the given number of
hours. |
static DefaultDuration |
fromMilliseconds(double milliseconds)
Creates a new
DefaultDuration from the given number of
milliseconds. |
static DefaultDuration |
fromMinutes(double minutes)
Creates a new
DefaultDuration from the given number of
minutes. |
static DefaultDuration |
fromSeconds(double seconds)
Creates a new
DefaultDuration from the given number of
seconds. |
long |
getDaysPart()
Gets the standard minutes part of the time.
|
int |
getHoursPart()
Gets the standard hours part of the time.
|
int |
getMillisecondsPart()
Gets the standard milliseconds part of the time.
|
int |
getMinutesPart()
Gets the standard minutes part of the time.
|
int |
getSecondsPart()
Gets the standard seconds part of the time.
|
double |
getTotalDays()
Gets the total number of standard days of this duration.
|
double |
getTotalHours()
Gets the total number of standard hours of this duration.
|
double |
getTotalMilliseconds()
Gets the total number of standard milliseconds of this duration.
|
double |
getTotalMinutes()
Gets the total number of standard minutes of this duration.
|
double |
getTotalSeconds()
Gets the total number of standard seconds of this duration.
|
int |
hashCode() |
Duration |
minus(Duration other)
Subtracts the given duration from this duration and returns the
difference.
|
Duration |
negative()
Returns the negative of this duration.
|
Duration |
plus(Duration other)
Adds this duration to the given duration and returns the sum.
|
Duration |
times(double scalar)
Multiplies this duration by the given scalar value and returns the
product.
|
java.lang.String |
toString() |
clone
public static final int MILLISECONDS_PER_SECOND
public static final int SECONDS_PER_MINUTE
public static final int MINUTES_PER_HOUR
public static final int HOURS_PER_DAY
public static final int MILLISECONDS_PER_MINUTE
public static final int MILLISECONDS_PER_HOUR
public static final int MILLISECONDS_PER_DAY
public static final DefaultDuration ZERO
public static final DefaultDuration MILLISECOND
public static final DefaultDuration SECOND
public static final DefaultDuration MINUTE
public static final DefaultDuration HOUR
public static final DefaultDuration DAY
public static final DefaultDuration MIN_VALUE
public static final DefaultDuration MAX_VALUE
public static final java.text.DecimalFormat THREE_DIGIT_FORMAT
protected DefaultDuration(double milliseconds)
DefaultDuration
representing the given number of
milliseconds. To create instances of this class, the factory methods
(from*) should be used instead of this constructor, to avoid confusion
with the types of units used to construct the class.milliseconds
- The duration in milliseconds.public static DefaultDuration fromMilliseconds(double milliseconds)
DefaultDuration
from the given number of
milliseconds.milliseconds
- The number of milliseconds.public static DefaultDuration fromSeconds(double seconds)
DefaultDuration
from the given number of
seconds.seconds
- The number of seconds.public static DefaultDuration fromMinutes(double minutes)
DefaultDuration
from the given number of
minutes.minutes
- The number of minutes.public static DefaultDuration fromHours(double hours)
DefaultDuration
from the given number of
hours.hours
- The number of hours.public static DefaultDuration fromDays(double days)
DefaultDuration
from the given number of
days.days
- The number of days.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public boolean equals(Duration other)
Duration
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(Duration other)
compareTo
in interface java.lang.Comparable<Duration>
public Duration negative()
Duration
public Duration absoluteValue()
Duration
absoluteValue
in interface Duration
public Duration plus(Duration other)
Duration
public Duration minus(Duration other)
Duration
public Duration times(double scalar)
Duration
public double divide(Duration other)
Duration
public Duration divide(double scalar)
Duration
public double getTotalMilliseconds()
Duration
getTotalMilliseconds
in interface Duration
public double getTotalSeconds()
Duration
getTotalSeconds
in interface Duration
public double getTotalMinutes()
Duration
getTotalMinutes
in interface Duration
public double getTotalHours()
Duration
getTotalHours
in interface Duration
public double getTotalDays()
Duration
getTotalDays
in interface Duration
public int getMillisecondsPart()
Duration
getMillisecondsPart
in interface Duration
public int getSecondsPart()
Duration
getSecondsPart
in interface Duration
public int getMinutesPart()
Duration
getMinutesPart
in interface Duration
public int getHoursPart()
Duration
getHoursPart
in interface Duration
public long getDaysPart()
Duration
getDaysPart
in interface Duration
public java.lang.String toString()
toString
in class java.lang.Object