

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.joda.time.base.AbstractDuration org.joda.time.base.BaseDuration org.joda.time.Duration
public final class 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.
Duration is threadsafe and immutable.
Field Summary  

static Duration 
ZERO
Constant representing zero millisecond duration 
Constructor Summary  

Duration(long duration)
Creates a duration from the given millisecond duration. 

Duration(long startInstant,
long endInstant)
Creates a duration from the given interval endpoints. 

Duration(Object duration)
Creates a duration from the specified object using the ConverterManager . 

Duration(ReadableInstant start,
ReadableInstant end)
Creates a duration from the given interval endpoints. 
Method Summary  

Duration 
dividedBy(long divisor)
Returns a new duration with this length divided by the specified divisor. 
long 
getStandardDays()
Gets the length of this duration in days assuming that there are the standard number of milliseconds in a day. 
long 
getStandardHours()
Gets the length of this duration in hours assuming that there are the standard number of milliseconds in an hour. 
long 
getStandardMinutes()
Gets the length of this duration in minutes assuming that there are the standard number of milliseconds in a minute. 
long 
getStandardSeconds()
Gets the length of this duration in seconds assuming that there are the standard number of milliseconds in a second. 
static Duration 
millis(long millis)
Create a duration with the specified number of milliseconds. 
Duration 
minus(long amount)
Returns a new duration with this length minus that specified. 
Duration 
minus(ReadableDuration amount)
Returns a new duration with this length minus that specified. 
Duration 
multipliedBy(long multiplicand)
Returns a new duration with this length multiplied by the specified multiplicand. 
Duration 
negated()
Returns a new duration with this length negated. 
static Duration 
parse(String str)
Parses a Duration from the specified string. 
Duration 
plus(long amount)
Returns a new duration with this length plus that specified. 
Duration 
plus(ReadableDuration amount)
Returns a new duration with this length plus that specified. 
static Duration 
standardDays(long days)
Create a duration with the specified number of days assuming that there are the standard number of milliseconds in a day. 
static Duration 
standardHours(long hours)
Create a duration with the specified number of hours assuming that there are the standard number of milliseconds in an hour. 
static Duration 
standardMinutes(long minutes)
Create a duration with the specified number of minutes assuming that there are the standard number of milliseconds in a minute. 
static Duration 
standardSeconds(long seconds)
Create a duration with the specified number of seconds assuming that there are the standard number of milliseconds in a second. 
Duration 
toDuration()
Get this duration as an immutable Duration object
by returning this . 
Days 
toStandardDays()
Converts this duration to a period in days assuming that there are the standard number of milliseconds in a day. 
Hours 
toStandardHours()
Converts this duration to a period in hours assuming that there are the standard number of milliseconds in an hour. 
Minutes 
toStandardMinutes()
Converts this duration to a period in minutes assuming that there are the standard number of milliseconds in a minute. 
Seconds 
toStandardSeconds()
Converts this duration to a period in seconds assuming that there are the standard number of milliseconds in a second. 
Duration 
withDurationAdded(long durationToAdd,
int scalar)
Returns a new duration with this length plus that specified multiplied by the scalar. 
Duration 
withDurationAdded(ReadableDuration durationToAdd,
int scalar)
Returns a new duration with this length plus that specified multiplied by the scalar. 
Duration 
withMillis(long duration)
Creates a new Duration instance with a different millisecond length. 
Methods inherited from class org.joda.time.base.BaseDuration 

getMillis, setMillis, toIntervalFrom, toIntervalTo, toPeriod, toPeriod, toPeriod, toPeriodFrom, toPeriodFrom, toPeriodTo, toPeriodTo 
Methods inherited from class org.joda.time.base.AbstractDuration 

compareTo, equals, hashCode, isEqual, isLongerThan, isShorterThan, toPeriod, toString 
Methods inherited from class java.lang.Object 

clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Methods inherited from interface org.joda.time.ReadableDuration 

equals, getMillis, hashCode, isEqual, isLongerThan, isShorterThan, toPeriod, toString 
Methods inherited from interface java.lang.Comparable 

compareTo 
Field Detail 

public static final Duration ZERO
Constructor Detail 

public Duration(long duration)
duration
 the duration, in millisecondspublic Duration(long startInstant, long endInstant)
startInstant
 interval start, in millisecondsendInstant
 interval end, in milliseconds
ArithmeticException
 if the duration exceeds a 64bit longpublic Duration(ReadableInstant start, ReadableInstant end)
start
 interval start, null means nowend
 interval end, null means now
ArithmeticException
 if the duration exceeds a 64bit longpublic Duration(Object duration)
ConverterManager
.
duration
 duration to convert
IllegalArgumentException
 if duration is invalidMethod Detail 

public static Duration parse(String str)
Duration
from the specified string.
This parses the format PTa.bS
, as per AbstractDuration.toString()
.
str
 the string to parse, not nullpublic static Duration standardDays(long days)
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 concept 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 largepublic static Duration standardHours(long hours)
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 concept 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 largepublic static Duration standardMinutes(long minutes)
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 concept 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 largepublic static Duration standardSeconds(long seconds)
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 concept 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 largepublic static Duration millis(long millis)
millis
 the number of standard milliseconds in this duration
public long getStandardDays()
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.
This returns getMillis() / MILLIS_PER_DAY
.
The result is an integer division, thus excess milliseconds are truncated.
public long getStandardHours()
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.
This returns getMillis() / MILLIS_PER_HOUR
.
The result is an integer division, thus excess milliseconds are truncated.
public long getStandardMinutes()
This method assumes that there are 60 seconds in a minute and 1000 milliseconds in a second. All currently supplied chronologies use this definition.
This returns getMillis() / 60000
.
The result is an integer division, thus excess milliseconds are truncated.
public long getStandardSeconds()
This method assumes that there are 1000 milliseconds in a second. All currently supplied chronologies use this definition.
This returns getMillis() / 1000
.
The result is an integer division, so 2999 millis returns 2 seconds.
public Duration toDuration()
Duration
object
by returning this
.
toDuration
in interface ReadableDuration
toDuration
in class AbstractDuration
this
public Days toStandardDays()
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.
ArithmeticException
 if the number of days is too large to be representedpublic Hours toStandardHours()
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.
ArithmeticException
 if the number of hours is too large to be representedpublic Minutes toStandardMinutes()
This method assumes that there are 60 seconds in a minute and 1000 milliseconds in a second. All currently supplied chronologies use this definition.
ArithmeticException
 if the number of minutes is too large to be representedpublic Seconds toStandardSeconds()
This method assumes that there are 1000 milliseconds in a second. All currently supplied chronologies use this definition.
ArithmeticException
 if the number of seconds is too large to be representedpublic Duration withMillis(long duration)
duration
 the new length of the duration
public Duration withDurationAdded(long durationToAdd, int scalar)
If the addition is zero, this instance is returned.
durationToAdd
 the duration to add to this onescalar
 the amount of times to add, such as 1 to subtract once
public Duration withDurationAdded(ReadableDuration durationToAdd, int scalar)
If the addition is zero, this instance is returned.
durationToAdd
 the duration to add to this one, null means zeroscalar
 the amount of times to add, such as 1 to subtract once
public Duration plus(long amount)
If the addition is zero, this instance is returned.
amount
 the duration to add to this one
public Duration plus(ReadableDuration amount)
If the amount is zero, this instance is returned.
amount
 the duration to add to this one, null means zero
public Duration minus(long amount)
If the addition is zero, this instance is returned.
amount
 the duration to take away from this one
public Duration minus(ReadableDuration amount)
If the amount is zero, this instance is returned.
amount
 the duration to take away from this one, null means zero
public Duration multipliedBy(long multiplicand)
If the multiplicand is one, this instance is returned.
multiplicand
 the multiplicand to multiply this one by
public Duration dividedBy(long divisor)
If the divisor is one, this instance is returned.
divisor
 the divisor to divide this one by
public Duration negated()


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 