org.goda.time
public abstract class DurationField extends Field implements Comparable
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 and Description |
|---|
DurationField() |
| Modifier and Type | Method and Description |
|---|---|
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 |
compareTo(Object durationField)
Compares this duration field with another duration field for ascending
unit millisecond order.
|
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 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.
|
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.
|
getDifference, getDifferenceAsLong, getName, isSupportedpublic abstract DurationFieldType getType()
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 negativeArithmeticException - if the value is too large for an intpublic abstract long getValueAsLong(long duration)
duration - the milliseconds to query, which may be negativepublic 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 toArithmeticException - 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 topublic abstract long getMillis(int value)
value - the value of the field, which may be negativepublic abstract long getMillis(long value)
value - the value of the field, which may be negativepublic 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 topublic 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 topublic abstract long add(long instant,
int value)
public abstract long add(long instant,
long value)
public long subtract(long instant,
int value)
instant - the milliseconds from 1970-01-01T00:00:00Z to subtract fromvalue - the value to subtract, in the units of the fieldpublic long subtract(long instant,
long value)
instant - the milliseconds from 1970-01-01T00:00:00Z to subtract fromvalue - the value to subtract, in the units of the fieldpublic abstract int compareTo(Object durationField)
compareTo in interface ComparabledurationField - a duration field to check againstNullPointerException - if the object is nullClassCastException - if the object type is not supportedCopyright © 2013 os-cillation GmbH. All rights reserved.