

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.joda.time.DurationField
public abstract class DurationField
Defines the calculation engine for duration fields. The interface defines a set of methods that manipulate a millisecond duration with regards to a single field, such as months or seconds.
This design is extensible so, if you wish, you can extract a different field from the millisecond duration. A number of standard implementations are provided to assist.
Constructor Summary  

DurationField()

Method Summary  

abstract long 
add(long instant,
int value)
Adds a duration value (which may be negative) to the instant. 
abstract long 
add(long instant,
long value)
Adds a duration value (which may be negative) to the instant. 
abstract int 
getDifference(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units of this field. 
abstract long 
getDifferenceAsLong(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units of this field. 
abstract long 
getMillis(int value)
Get the millisecond duration of this field from its value, which is approximate if this field is imprecise. 
abstract long 
getMillis(int value,
long instant)
Get the millisecond duration of this field from its value relative to an instant. 
abstract long 
getMillis(long value)
Get the millisecond duration of this field from its value, which is approximate if this field is imprecise. 
abstract long 
getMillis(long value,
long instant)
Get the millisecond duration of this field from its value relative to an instant. 
abstract String 
getName()
Get the name of the field. 
abstract DurationFieldType 
getType()
Get the type of the field. 
abstract long 
getUnitMillis()
Returns the amount of milliseconds per unit value of this field. 
abstract int 
getValue(long duration)
Get the value of this field from the milliseconds, which is approximate if this field is imprecise. 
abstract int 
getValue(long duration,
long instant)
Get the value of this field from the milliseconds relative to an instant. 
abstract long 
getValueAsLong(long duration)
Get the value of this field from the milliseconds, which is approximate if this field is imprecise. 
abstract long 
getValueAsLong(long duration,
long instant)
Get the value of this field from the milliseconds relative to an instant. 
abstract boolean 
isPrecise()
Is this field precise. 
abstract boolean 
isSupported()
Returns true if this field is supported. 
long 
subtract(long instant,
int value)
Subtracts a duration value (which may be negative) from the instant. 
long 
subtract(long instant,
long value)
Subtracts a duration value (which may be negative) from the instant. 
abstract String 
toString()
Get a suitable debug string. 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Methods inherited from interface java.lang.Comparable 

compareTo 
Constructor Detail 

public DurationField()
Method Detail 

public abstract DurationFieldType getType()
public abstract String getName()
By convention, names are plural.
public abstract boolean isSupported()
public abstract boolean isPrecise()
getUnitMillis()
public abstract long getUnitMillis()
For imprecise fields, the unit size is variable, and so this method returns a suitable average value.
isPrecise()
public abstract int getValue(long duration)
duration
 the milliseconds to query, which may be negative
ArithmeticException
 if the value is too large for an intpublic abstract long getValueAsLong(long duration)
duration
 the milliseconds to query, which may be negative
public abstract int getValue(long duration, long instant)
If the millisecond duration is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
duration
 the milliseconds to query, which may be negativeinstant
 the start instant to calculate relative to
ArithmeticException
 if the value is too large for an intpublic abstract long getValueAsLong(long duration, long instant)
If the millisecond duration is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
duration
 the milliseconds to query, which may be negativeinstant
 the start instant to calculate relative to
public abstract long getMillis(int value)
value
 the value of the field, which may be negative
public abstract long getMillis(long value)
value
 the value of the field, which may be negative
public abstract long getMillis(int value, long instant)
If the value is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
value
 the value of the field, which may be negativeinstant
 the instant to calculate relative to
public abstract long getMillis(long value, long instant)
If the value is positive, then the instant is treated as a "start instant". If negative, the instant is treated as an "end instant".
value
 the value of the field, which may be negativeinstant
 the instant to calculate relative to
public abstract long add(long instant, int value)
instant
 the milliseconds from 19700101T00:00:00Z to add tovalue
 the value to add, in the units of the field
public abstract long add(long instant, long value)
instant
 the milliseconds from 19700101T00:00:00Z to add tovalue
 the value to add, in the units of the field
public long subtract(long instant, int value)
instant
 the milliseconds from 19700101T00:00:00Z to subtract fromvalue
 the value to subtract, in the units of the field
public long subtract(long instant, long value)
instant
 the milliseconds from 19700101T00:00:00Z to subtract fromvalue
 the value to subtract, in the units of the field
public abstract int getDifference(long minuendInstant, long subtrahendInstant)
long instant = ... int v = ... int age = getDifference(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract fromsubtrahendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract off the minuend
public abstract long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract fromsubtrahendInstant
 the milliseconds from 19700101T00:00:00Z to
subtract off the minuend
public abstract String toString()
toString
in class Object


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