java.lang.Object | |||
↳ | org.joda.time.base.AbstractDuration | ||
↳ | org.joda.time.base.BaseDuration | ||
↳ | org.joda.time.Duration |
An immutable duration specifying a length of time in milliseconds.
A duration is defined by a fixed number of milliseconds.
There is no concept of fields, such as days or seconds, as these fields can vary in length.
A duration may be converted to a Period
to obtain field values.
This conversion will typically cause a loss of precision however.
Duration is thread-safe and immutable.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ZERO | Constant representing zero millisecond duration |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a duration from the given millisecond duration.
| |||||||||||
Creates a duration from the given interval endpoints.
| |||||||||||
Creates a duration from the given interval endpoints.
| |||||||||||
Creates a duration from the specified object using the
ConverterManager . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the length of this duration in seconds assuming 1000 milliseconds
in a second.
| |||||||||||
Returns a new duration with this length minus that specified.
| |||||||||||
Returns a new duration with this length minus that specified.
| |||||||||||
Returns a new duration with this length plus that specified.
| |||||||||||
Returns a new duration with this length plus that specified.
| |||||||||||
Create a duration with the specified number of days assuming that
there are the standard number of milliseconds in a day.
| |||||||||||
Create a duration with the specified number of hours assuming that
there are the standard number of milliseconds in an hour.
| |||||||||||
Create a duration with the specified number of minutes assuming that
there are the standard number of milliseconds in a minute.
| |||||||||||
Create a duration with the specified number of seconds assuming that
there are the standard number of milliseconds in a second.
| |||||||||||
Get this duration as an immutable
Duration object
by returning this . | |||||||||||
Converts this duration to a period in seconds assuming 1000 milliseconds
in a second.
| |||||||||||
Returns a new duration with this length plus that specified multiplied by the scalar.
| |||||||||||
Returns a new duration with this length plus that specified multiplied by the scalar.
| |||||||||||
Creates a new Duration instance with a different milisecond length.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Creates a duration from the given millisecond duration.
duration | the duration, in milliseconds |
---|
Creates a duration from the given interval endpoints.
startInstant | interval start, in milliseconds |
---|---|
endInstant | interval end, in milliseconds |
ArithmeticException | if the duration exceeds a 64 bit long |
---|
Creates a duration from the given interval endpoints.
start | interval start, null means now |
---|---|
end | interval end, null means now |
ArithmeticException | if the duration exceeds a 64 bit long |
---|
Creates a duration from the specified object using the
ConverterManager
.
duration | duration to convert |
---|
IllegalArgumentException | if duration is invalid |
---|
Gets the length of this duration in seconds assuming 1000 milliseconds in a second.
This returns getMillis() / 1000
.
The result is an integer division, so 2999 millis returns 2 seconds.
Returns a new duration with this length minus that specified. This instance is immutable and is not altered.
If the addition is zero, this instance is returned.
amount | the duration to take away from this one |
---|
Returns a new duration with this length minus that specified. This instance is immutable and is not altered.
If the amount is zero, this instance is returned.
amount | the duration to take away from this one, null means zero |
---|
Returns a new duration with this length plus that specified. This instance is immutable and is not altered.
If the amount is zero, this instance is returned.
amount | the duration to add to this one, null means zero |
---|
Returns a new duration with this length plus that specified. This instance is immutable and is not altered.
If the addition is zero, this instance is returned.
amount | the duration to add to this one |
---|
Create a duration with the specified number of days assuming that there are the standard number of milliseconds in a day.
This method assumes that there are 24 hours in a day, 60 minutes in an hour, 60 seconds in a minute and 1000 milliseconds in a second. This will be true for most days, however days with Daylight Savings changes will not have 24 hours, so use this method with care.
A Duration is a representation of an amount of time. If you want to express
the concepts of 'days' you should consider using the Days
class.
days | the number of standard days in this duration |
---|
ArithmeticException | if the days value is too large |
---|
Create a duration with the specified number of hours assuming that there are the standard number of milliseconds in an hour.
This method assumes that there are 60 minutes in an hour, 60 seconds in a minute and 1000 milliseconds in a second. All currently supplied chronologies use this definition.
A Duration is a representation of an amount of time. If you want to express
the concepts of 'hours' you should consider using the Hours
class.
hours | the number of standard hours in this duration |
---|
ArithmeticException | if the hours value is too large |
---|
Create a duration with the specified number of minutes assuming that there are the standard number of milliseconds in a minute.
This method assumes that there are 60 seconds in a minute and 1000 milliseconds in a second. All currently supplied chronologies use this definition.
A Duration is a representation of an amount of time. If you want to express
the concepts of 'minutes' you should consider using the Minutes
class.
minutes | the number of standard minutes in this duration |
---|
ArithmeticException | if the minutes value is too large |
---|
Create a duration with the specified number of seconds assuming that there are the standard number of milliseconds in a second.
This method assumes that there are 1000 milliseconds in a second. All currently supplied chronologies use this definition.
A Duration is a representation of an amount of time. If you want to express
the concepts of 'seconds' you should consider using the Seconds
class.
seconds | the number of standard seconds in this duration |
---|
ArithmeticException | if the seconds value is too large |
---|
Get this duration as an immutable Duration
object
by returning this
.
this
Converts this duration to a period in seconds assuming 1000 milliseconds in a second.
This method allows you to convert between a duration and a period.
ArithmeticException | if the number of seconds is too large to be represented |
---|
Returns a new duration with this length plus that specified multiplied by the scalar. This instance is immutable and is not altered.
If the addition is zero, this instance is returned.
durationToAdd | the duration to add to this one |
---|---|
scalar | the amount of times to add, such as -1 to subtract once |
Returns a new duration with this length plus that specified multiplied by the scalar. This instance is immutable and is not altered.
If the addition is zero, this instance is returned.
durationToAdd | the duration to add to this one, null means zero |
---|---|
scalar | the amount of times to add, such as -1 to subtract once |
Creates a new Duration instance with a different milisecond length.
duration | the new length of the duration |
---|